Archived Support Site

This support site is archived. You can view the old support discussions but you cannot post new discussions.

HostingEnvironment.QueueBackgroundWorkItem Method (Action<CancellationToken>)

ibanezjp's Avatar


27 Dec, 2017 05:34 PM

Is HostingEnvironment.QueueBackgroundWorkItem Method (Action<CancellationToken>) supported in AppHarbor?

  1. Support Staff 1 Posted by rune on 30 Dec, 2017 01:15 AM

    rune's Avatar


    It's supported in the sense that you can use it to queue items for processing in the background, but notably the application is usually shut down immediately after a platform-related shutdown (e.g. when the application is redeployed). For background processing I'd generally recommend using AppHarbor's background workers combined with for instance a queue processing system.

    That said, if your app (web or background worker) needs to perform certain tasks during shutdown we have a model for graceful worker shutdown is currently in beta. You're more than welcome to use it: AppHarbor will signal an upcoming shutdown of a worker process by simply writing a file to a know location that your application can monitor for changes. The location of the file to monitor is injected as an environment variable (WORKER_SHUTDOWN_FILE).

    When the file is written your application has 10 seconds to release any resources and exit before it is forcibly terminated. Take a look at this Gist showing a simple worker that monitors the shutdown file and performs cleanup logic.

    Let me know if you hit any snags or have feedback on how the feature can be improved!


Discussions are closed to public comments.
If you need help with AppHarbor please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac