Hangfire.Core Provides extension methods for the IAppBuilder interface defined in the Owin NuGet package to simplify the integration with OWIN applications. This class simplifies Hangfire configuration in OWIN applications, please read Getting Started with OWIN and Katana if you aren't familiar with OWIN and/or don't know what is the Startup class. The methods of this class should be called from OWIN's Startup class.

UseHangfireDashboard

Dashboard UI contains pages that allow you to monitor almost every aspect of background processing. It is exposed as an OWIN middleware that intercepts requests to the given path. OWIN implementation of Dashboard UI allows to use it outside of web applications, including console applications and Windows Services. By default, an access to the Dashboard UI is restricted only to local requests for security reasons. Before publishing a project to production, make sure you still have access to the Dashboard UI by using the Hangfire.Dashboard.Authorization package.

UseHangfireServer

In addition to creation of a new instance of the class, these methods also register the call to its method on application shutdown. This is done via registering a callback on the corresponding from OWIN environment ("host.OnAppDisposing" or "server.OnDispose" keys). This enables graceful shutdown feature for background jobs and background processes without any additional configuration. Please see for more details regarding background processing.

Basic Configuration

Basic setup in an OWIN application looks like the following example. Please note that job storage should be configured before using the methods of this class.

Adding Dashboard Only

If you want to install dashboard without starting a background job server, for example, to process background jobs outside of your web application, call only the .

Change Dashboard Path

By default, you can access Dashboard UI by hitting the http(s)://<app>/hangfire URL, however you can change it as in the following example.

Configuring Authorization

The following example demonstrates how to change default local-requests-only authorization for Dashboard UI.

Changing Application Path

Have you seen the Back to site button in the Dashboard? By default it leads you to the root of your site, but you can configure the behavior.

Multiple Dashboards

The following example demonstrates adding multiple Dashboard UI endpoints. This may be useful when you are using multiple shards for your background processing needs.
Hangfire.Dashboard.Authorization Package
Creates a new instance of the class with default options and storage and registers its disposal on application shutdown. OWIN application builder. is null. OWIN environment does not contain the application shutdown cancellation token. Please see for details and examples. Creates a new instance of the class with the given collection of additional background processes and storage, and registers its disposal on application shutdown. OWIN application builder. Collection of additional background processes. is null. is null. OWIN environment does not contain the application shutdown cancellation token. Please see for details and examples. Creates a new instance of the class with the specified options and storage, and registers its disposal on application shutdown. OWIN application builder. Options for background job server. is null. is null. OWIN environment does not contain the application shutdown cancellation token. Please see for details and examples. Creates a new instance of the class with the specified options, given collection of background processes and storage, and registers its disposal on application shutdown. OWIN application builder. Options for background job server. Collection of additional background processes. is null. is null. is null. OWIN environment does not contain the application shutdown cancellation token. Please see for details and examples. Creates a new instance of the class with the given options and specified storage, and registers its disposal on application shutdown. OWIN application builder. Options for background job server. Storage to use by background job server. is null. is null. is null. OWIN environment does not contain the application shutdown cancellation token. Please see for details and examples. Starts a new instance of the class with the given arguments, and registers its disposal on application shutdown. OWIN application builder. Storage to use by background job server. Options for background job server. Collection of additional background processes. is null. is null. is null. is null. OWIN environment does not contain the application shutdown cancellation token. Please see for details and examples. Adds Dashboard UI middleware to the OWIN request processing pipeline under the /hangfire path, for the storage. OWIN application builder. is null. Please see for details and examples. Adds Dashboard UI middleware to the OWIN request processing pipeline under the given path, for the storage. OWIN application builder. Path prefix for middleware to use, e.g. "/hangfire". is null. is null. Please see for details and examples. Adds Dashboard UI middleware to the OWIN request processing pipeline under the specified path and the given options, for the storage. OWIN application builder. Path prefix for middleware to use, e.g. "/hangfire". Options for Dashboard UI. is null. is null. is null. Please see for details and examples. Adds Dashboard UI middleware to the OWIN request processing pipeline with the specified parameters. OWIN application builder. Path prefix for middleware to use, e.g. "/hangfire". Options for Dashboard UI. Job storage to use by Dashboard IO. is null. is null. is null. is null. Please see for details and examples. Adds Dashboard UI middleware to the OWIN request processing pipeline with the specified parameters and antiforgery service. OWIN application builder. Path prefix for middleware to use, e.g. "/hangfire". Options for Dashboard UI. Job storage to use by Dashboard IO. Antiforgery service. is null. is null. is null. is null. Please see for details and examples. Simple interface that represent a logger. Log a message the specified log level. The log level. The message function. An optional exception. true if the message was logged. Otherwise false. Note to implementers: the message func should not be called if the loglevel is not enabled so as not to incur performance penalties. To check IsEnabled call Log with only LogLevel and check the return value, no event will be written The log level. Represents a way to get a Provides a mechanism to create instances of objects. Gets a logger for the specified type. The type whose name will be used for the logger. An instance of Gets a logger for the current class. An instance of Gets a logger for the specified type. The type whose name will be used for the logger. An instance of Gets a logger with the specified name. The name. An instance of Sets the current log provider. The log provider. Gets or sets a value indicating whether [provider is available override]. Used in tests. true if [provider is available override]; otherwise, false. The form of the Loupe Log.Write method we're using A delegate returning a formatted log message The name of the Logger The Log Level The Log Message The Exception, if there is one A formatted Log Message string. The namespace contains types for supporting most popular logging frameworks to simplify the logging integration with your projects. The Hangfire.Logging namespaces contain types that allow you to integrate Hangfire's logging with your projects as well as use it to log custom messages. The namespace contains types that allow you to integrate Hangfire's logging with your projects as well as use it to log custom messages. Specifies a candidate state for a background job that will be chosen by the filter after exceeding the number of retry attempts. Background job will be moved to the . Background job will be moved to the . Represents a job filter that performs automatic retries for background jobs whose processing was failed due to an exception, with a limited number of attempts. Filter is added to the global collection by default. Intervals between attempts are based on increasing exponential back-off multiplier in seconds. This filter works in a state election phase by changing the candidate state from to the when another retry should be attempted, or other state based on the value of the property when attempts exceeded.

Disabling Automatic Retries

The following example shows how to disable automatic retries for a specific job method by applying an attribute to a method. Even if you disable filter, your background jobs can still be executed several times, due to re-queue on shutdown and other compensation logic that guarantees the at least once processing.

Overriding Defaults

The following example shows how to override the default number of retry attempts for all of the background jobs by modifying the global collection.

Specifying Attempts Exceeded Action

The following example shows how to ignore a background job when number of retry attempts exceed using the property. Choose action when you aren't interested in processing background job that failed several times.
Represents the default number of retry attempts. This field is read-only. The value of this field is 10. Initializes a new instance of the class with number. Gets or sets the maximum number of automatic retry attempts. Any non-negative number. The value in a set operation is less than zero. Gets or sets the delays between attempts. An array of non-negative numbers. The value in a set operation is null. The value contain one or more negative numbers. Gets or sets a function using to get a delay by an attempt number. The value in a set operation is null. Gets or sets a candidate state for a background job that will be chosen when number of retry attempts exceeded. Gets or sets whether to produce log messages on retry attempts. Schedules the job to run again later. See . The state context. The count of retry attempts made so far. Object which contains details about the current failed state. Transition the candidate state to the deleted state. The state context. Object which contains details about the current failed state. Provides static methods for creating fire-and-forget, delayed jobs and continuations as well as re-queue and delete existing background jobs. This class is a wrapper for the interface and its default implementation, class, that was created for the most simple scenarios. Please consider using the types above in real world applications. This class also contains undocumented constructor and instance members. They are hidden to not to confuse new users. You can freely use them in low-level API. Creates a new fire-and-forget job based on a given method call expression. Method call expression that will be marshalled to a server. Unique identifier of a background job. is . Creates a new fire-and-forget job based on a given method call expression. Method call expression that will be marshalled to a server. Unique identifier of a background job. is . Creates a new fire-and-forget job based on a given method call expression. Method call expression that will be marshalled to a server. Unique identifier of a background job. is . Creates a new fire-and-forget job based on a given method call expression. Method call expression that will be marshalled to a server. Unique identifier of a background job. is . Creates a new background job based on a specified method call expression and schedules it to be enqueued after a given delay. Instance method call expression that will be marshalled to the Server. Delay, after which the job will be enqueued. Unique identifier of the created job. Creates a new background job based on a specified method call expression and schedules it to be enqueued after a given delay. Instance method call expression that will be marshalled to the Server. Delay, after which the job will be enqueued. Unique identifier of the created job. Creates a new background job based on a specified method call expression and schedules it to be enqueued at the given moment of time. Method call expression that will be marshalled to the Server. The moment of time at which the job will be enqueued. Unique identifier of a created job. Creates a new background job based on a specified method call expression and schedules it to be enqueued at the given moment of time. Method call expression that will be marshalled to the Server. The moment of time at which the job will be enqueued. Unique identifier of a created job. Creates a new background job based on a specified instance method call expression and schedules it to be enqueued after a given delay. Type whose method will be invoked during job processing. Instance method call expression that will be marshalled to the Server. Delay, after which the job will be enqueued. Unique identifier of the created job. Creates a new background job based on a specified instance method call expression and schedules it to be enqueued after a given delay. Type whose method will be invoked during job processing. Instance method call expression that will be marshalled to the Server. Delay, after which the job will be enqueued. Unique identifier of the created job. Creates a new background job based on a specified method call expression and schedules it to be enqueued at the given moment of time. The type whose method will be invoked during the job processing. Method call expression that will be marshalled to the Server. The moment of time at which the job will be enqueued. Unique identifier of a created job. Creates a new background job based on a specified method call expression and schedules it to be enqueued at the given moment of time. The type whose method will be invoked during the job processing. Method call expression that will be marshalled to the Server. The moment of time at which the job will be enqueued. Unique identifier of a created job. Changes state of a job with the specified to the . An identifier, that will be used to find a job. True on a successfull state transition, false otherwise. Changes state of a job with the specified to the . State change is only performed if current job state is equal to the value. Identifier of job, whose state is being changed. Current state assertion, or null if unneeded. True, if state change succeeded, otherwise false. Changes state of a job with the specified to the . Identifier of job, whose state is being changed. True, if state change succeeded, otherwise false. Changes state of a job with the specified to the . If value is not null, state change will be performed only if the current state name of a job equal to the given value. Identifier of job, whose state is being changed. Current state assertion, or null if unneeded. True, if state change succeeded, otherwise false. Creates a new background job that will wait for a successful completion of another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Unique identifier of a created job. Creates a new background job that will wait for another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. By default, is used. Unique identifier of a created job. Creates a new background job that will wait for another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. By default, is used. Unique identifier of a created job. Creates a new background job that will wait for another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. By default, is used. Unique identifier of a created job. Creates a new background job that will wait for another background job to be enqueued. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. By default, is used. Unique identifier of a created job. Provides methods for creating all the types of background jobs and changing their states. Represents a default implementation of the interface. This class uses the interface for creating background jobs and the interface for changing their states. Please see documentation for those types and their implementations to learn the details. Despite the fact that instance methods of this class are thread-safe, most implementations of the interface are neither thread-safe, nor immutable. Please create a new instance of a state class for each operation to avoid race conditions and unexpected side effects. Initializes a new instance of the class with the storage from a global configuration. Please see the class for the details regarding the global configuration. Initializes a new instance of the class with the specified storage. Job storage to use for background jobs. is null. Initializes a new instance of the class with the specified storage and filter provider. Job storage to use for background jobs. Filter provider responsible to locate job filters. is null. is null. Initializes a new instance of the class with the specified storage, background job factory and state changer. Job storage to use for background jobs. Factory to create background jobs. State changer to change states of background jobs. is null. is null. is null. The exception that is thrown when an instance of the class that implements the interface is unable to perform an operation due to an error. Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. The error message that explains the reason for the exception. The exception that is the cause of this exception, not null. Provides extension methods for the interface to simplify the creation of fire-and-forget jobs, delayed jobs, continuations and other background jobs in well-known states. Also allows to re-queue and delete existing background jobs. Creates a background job based on a specified lambda expression and places it into its actual queue. Please, see the to learn how to place the job on a non-default queue. A job client instance. Static method call expression that will be marshalled to the Server. Unique identifier of the created job. Creates a background job based on a specified lambda expression and places it into its actual queue. Please, see the to learn how to place the job on a non-default queue. A job client instance. Static method call expression that will be marshalled to the Server. Unique identifier of the created job. Creates a background job based on a specified lambda expression and places it into its actual queue. Please, see the to learn how to place the job on a non-default queue. Type whose method will be invoked during job processing. A job client instance. Instance method call expression that will be marshalled to the Server. Unique identifier of the created job. Creates a background job based on a specified lambda expression and places it into its actual queue. Please, see the to learn how to place the job on a non-default queue. Type whose method will be invoked during job processing. A job client instance. Instance method call expression that will be marshalled to the Server. Unique identifier of the created job. Creates a new background job based on a specified lambda expression and schedules it to be enqueued after a given delay. A job client instance. Instance method call expression that will be marshalled to the Server. Delay, after which the job will be enqueued. Unique identifier of the created job. Creates a new background job based on a specified lambda expression and schedules it to be enqueued after a given delay. A job client instance. Instance method call expression that will be marshalled to the Server. Delay, after which the job will be enqueued. Unique identifier of the created job. Creates a new background job based on a specified lambda expression and schedules it to be enqueued at the specified moment of time. A job client instance. Method call expression that will be marshalled to the Server. Moment of time at which the job will be enqueued. Unique identifier or a created job. Creates a new background job based on a specified lambda expression and schedules it to be enqueued at the specified moment of time. A job client instance. Method call expression that will be marshalled to the Server. Moment of time at which the job will be enqueued. Unique identifier or a created job. Creates a new background job based on a specified instance method call expression and schedules it to be enqueued after a given delay. Type whose method will be invoked during job processing. A job client instance. Instance method call expression that will be marshalled to the Server. Delay, after which the job will be enqueued. Unique identifier of the created job. Creates a new background job based on a specified instance method call expression and schedules it to be enqueued after a given delay. Type whose method will be invoked during job processing. A job client instance. Instance method call expression that will be marshalled to the Server. Delay, after which the job will be enqueued. Unique identifier of the created job. Creates a new background job based on a specified lambda expression and schedules it to be enqueued at the specified moment. Type whose method will be invoked during job processing. A job client instance. Method call expression that will be marshalled to the Server. Moment at which the job will be enqueued. Unique identifier of a created job. Creates a new background job based on a specified lambda expression and schedules it to be enqueued at the specified moment. Type whose method will be invoked during job processing. A job client instance. Method call expression that will be marshalled to the Server. Moment at which the job will be enqueued. Unique identifier of a created job. Creates a new background job based on a specified lambda expression in a given state. A job client instance. Static method call expression that will be marshalled to the Server. Initial state of a job. Unique identifier of the created job. Creates a new background job based on a specified lambda expression in a given state. A job client instance. Static method call expression that will be marshalled to the Server. Initial state of a job. Unique identifier of the created job. Creates a new background job based on a specified instance method in a given state. Type whose method will be invoked during job processing. A job client instance. Instance method call expression that will be marshalled to the Server. Initial state of a job. Unique identifier of the created job. Creates a new background job based on a specified instance method in a given state. Type whose method will be invoked during job processing. A job client instance. Instance method call expression that will be marshalled to the Server. Initial state of a job. Unique identifier of the created job. Changes state of a job with the given to the specified one. An instance of implementation. A job, whose state is being changed. New state for a job. True, if state change succeeded, otherwise false. Changes state of a job with the specified to the . The job is not actually being deleted, this method changes only its state. This operation does not provides guarantee that the job will not be performed. If you deleting a job that is performing right now, it will be performed anyway, despite of this call. The method returns result of a state transition. It can be false if a job was expired, its method does not exist or there was an exception during the state change process. An instance of implementation. Identifier of job, whose state is being changed. True, if state change succeeded, otherwise false. Changes state of a job with the specified to the . If value is not null, state change will be performed only if the current state name of a job equal to the given value. The job is not actually being deleted, this method changes only its state. This operation does not provides guarantee that the job will not be performed. If you deleting a job that is performing right now, it will be performed anyway, despite of this call. The method returns result of a state transition. It can be false if a job was expired, its method does not exist or there was an exception during the state change process. An instance of implementation. Identifier of job, whose state is being changed. Current state assertion, or null if unneeded. True, if state change succeeded, otherwise false. Changes state of a job with the specified to the . An instance of implementation. Identifier of job, whose state is being changed. True, if state change succeeded, otherwise false. Changes state of a job with the specified to the . If value is not null, state change will be performed only if the current state name of a job equal to the given value. An instance of implementation. Identifier of job, whose state is being changed. Current state assertion, or null if unneeded. True, if state change succeeded, otherwise false. Creates a new background job that will wait for a successful completion of another background job to be triggered in the . A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be triggered in the . A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be triggered in the . A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be triggered in the . A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. If null, then is used. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. If null, then is used. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. If null, then is used. Unique identifier of a created job. Creates a new background job that will wait for a successful completion of another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. If null, then is used. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered in the . A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered in the . A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered in the . A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered in the . A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. If null, then is used. Continuation options. By default, is used. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. If null, then is used. Continuation options. By default, is used. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. Continuation options. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. If null, then is used. Continuation options. By default, is used. Unique identifier of a created job. Creates a new background job that will wait for another background job to be triggered. A job client instance. Identifier of a background job to wait completion for. Method call expression that will be marshalled to a server. Next state for a job, when continuation is triggered. If null, then is used. Continuation options. By default, is used. Unique identifier of a created job. Initializes a new instance of the class with default options and storage. Initializes a new instance of the class with default options and the given storage. The storage Initializes a new instance of the class with the given options and storage. Server options Initializes a new instance of the class with the specified options and the given storage. Server options The storage Provides the context for the method of the interface. Gets an exception that occurred during the creation of the job. Gets or sets a value that indicates that this object handles an exception occurred during the creation of the job. Provides information about the context in which the job is created. Gets an instance of the key-value storage. You can use it to pass additional information between different client filters or just between different methods. Gets the initial state of the creating job. Note, that the final state of the created job could be changed after the registered instances of the class are doing their job. Provides the context for the method of the interface. Gets an exception that occurred during the creation of the job. Gets a value that indicates that this object was canceled. Gets or sets a value that indicates that this object handles an exception occurred during the creation of the job. Provides the context for the method of the interface. Gets or sets a value that indicates that this object was canceled. Sets the job parameter of the specified to the corresponding . The value of the parameter is serialized to a JSON string. The name of the parameter. The value of the parameter. The is null or empty. Gets the job parameter of the specified if it exists. The parameter is deserialized from a JSON string value to the given type . The type of the parameter. The name of the parameter. The value of the given parameter if it exists or null otherwise. The is null or empty. Could not deserialize the parameter value to the type . This interface acts as extensibility point for the process of job creation. See the default implementation in the class. Gets a state machine that's responsible for initial state change. Runs the process of job creation with the specified context. Defines methods that are required for the client exception filter. Called when an exception occurred during the creation of the job. The filter context. Defines methods that are required for a client filter. Called before the creation of the job. The filter context. Called after the creation of the job. The filter context. The exception that is thrown when a class instance could not create a job due to another exception was thrown. Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. The error message that explains the reason for the exception. The exception that is the cause of this exception, not null. The namespace contains types that allow you to customize the background job creation pipeline using the , or define your own creation process by implementing the interface. The caching expression tree compiler was copied from MVC core to MVC Futures so that Futures code could benefit from it and so that it could be exposed as a public API. This is the only public entry point into the system. See the comments in the ExpressionUtil namespace for more information. The unit tests for the ExpressionUtil.* types are in the System.Web.Mvc.Test project. Evaluates an expression (not a LambdaExpression), e.g. 2 + 2. Expression result. Returns a class that contains a that is set, when the given is canceled. This method is based on cancellation token registration and avoids using the property as it may lead to high CPU issues. Performs a wait until the specified is elapsed or the given cancellation token is canceled. The wait is performed on a dedicated event wait handle to avoid using the property that may lead to high CPU issues. Defines members that specify the order of filters and whether multiple filters are allowed. When implemented in a class, gets or sets a value that indicates whether multiple filters are allowed. When implemented in a class, gets the filter order. Provides an interface for finding filters. Returns an enumerator that contains all the . The enumerator that contains all the . Represents an action that can be marshalled to another process to be performed. The ability to serialize an action is the cornerstone of marshalling it outside of a current process boundaries. We are leaving behind all the tricky features, e.g. serializing lambdas with their closures or so, and considering a simple method call information as a such an action, and using reflection to perform it. Reflection-based method invocation requires an instance of the class, the arguments and an instance of the type on which to invoke the method (unless it is static). Since the same instance can be shared across multiple types (especially when they are defined in interfaces), we also allow to specify a that contains the defined method explicitly for better flexibility. Marshalling imposes restrictions on a method that should be performed: Method should be public. Method should not contain and parameters. Method should not contain open generic parameters. The following example demonstrates the creation of a type instances using expression trees. This is the recommended way of creating jobs. The next example demonstrates unsupported methods. Any attempt to create a job based on these methods fails with . Initializes a new instance of the class with the metadata of a method with no arguments. Method that should be invoked. argument is null. is not supported. Initializes a new instance of the class with the metadata of a method and the given list of arguments. Method that should be invoked. Arguments that will be passed to a method invocation. argument is null. Parameter/argument count mismatch. is not supported. Initializes a new instance of the class with the type, metadata of a method with no arguments. Type that contains the given method. Method that should be invoked. argument is null. argument is null. does not contain the given . Parameter/argument count mismatch. is not supported. Initializes a new instance of the class with the type, metadata of a method and the given list of arguments. Type that contains the given method. Method that should be invoked. Arguments that should be passed during the method call. argument is null. argument is null. argument is null. does not contain the given . Parameter/argument count mismatch. is not supported. Gets the metadata of a type that contains a method that should be invoked during the performance. Gets the metadata of a method that should be invoked during the performance. Gets a read-only collection of arguments that Should be passed to a method invocation during the performance. Gets a new instance of the class based on the given expression tree of a method call. Expression tree of a method call. is null. expression body is not of type . expression contains a method that is not supported. instance object of a given expression points to . The property of a returning job will point to the type of a given instance object when it is specified, or to the declaring type otherwise. All the arguments are evaluated using the expression compiler that uses caching where possible to decrease the performance penalty. Instance object (e.g. () => instance.Method()) is only used to obtain the type for a job. It is not serialized and not passed across the process boundaries. Gets a new instance of the class based on the given expression tree of a method call. Expression tree of a method call. is null. expression body is not of type . expression contains a method that is not supported. instance object of a given expression points to . The property of a returning job will point to the type of a given instance object when it is specified, or to the declaring type otherwise. All the arguments are evaluated using the expression compiler that uses caching where possible to decrease the performance penalty. Instance object (e.g. () => instance.Method()) is only used to obtain the type for a job. It is not serialized and not passed across the process boundaries. Gets a new instance of the class based on the given expression tree of an instance method call with explicit type specification. Explicit type that should be used on method call. Expression tree of a method call on . is null. expression body is not of type . expression contains a method that is not supported. All the arguments are evaluated using the expression compiler that uses caching where possible to decrease the performance penalty. Gets a new instance of the class based on the given expression tree of an instance method call with explicit type specification. Explicit type that should be used on method call. Expression tree of a method call on . is null. expression body is not of type . expression contains a method that is not supported. All the arguments are evaluated using the expression compiler that uses caching where possible to decrease the performance penalty. Represents a metadata class that contains a reference to the implementation of one or more of the filter interfaces, the filter's order, and the filter's scope. Represents a constant that is used to specify the default ordering of filters. Initializes a new instance of the Filter class. Filter instance. Filter scope. The run order. Gets the instance of the filter. Gets the order in which the filter is applied. Gets the scope ordering of the filter. Represents the base class for job filter attributes. Defines a filter provider for filter attributes. Initializes a new instance of the class with the attribute instance caching enabled. Initializes a new instance of the class and optionally caches attribute instances. Represents a class that contains the job filters. Job filters run for every create, perform and state change of every job. All the instances in the filters collection should be thread-safe. You can register a filter using the registration endpoint. Gets the number of filters in the global job filter collection. Adds the specified filter to the global filter collection. The filter instance. Adds the specified filter to the global filter collection using the specified filter run order. The filter instance. The run order. Removes all filters from the global filter collection. Determines wheither a filter is in the global filter collection. The filter instance. True if the global filter collection contains the filter, otherwise false. Removes all filters that match the specified filter. The filter instance. Encapsulates information about the available job filters. Initializes a new instance of the class using the specified filters collection. The filters collection. Gets all the client filters in the application. The client filters. Gets all the server filters in the application. The server filters. Gets all the stat changing filters in the application. The state changing filters. Gets all the state changed filters in the application. The state changed filters. Gets all the client exception filters in the application. The client exception filters. Gets all the server exception filters in the application. The server exception filters. Represents the collection of filter providers for the application. Initializes a new instance of the class. Returns the collection of filter providers. Job, can be null. The collection of filter providers. Provides a registration point for filters. Provides a registration point for filters. Defines values that specify the order in which Hangfire filters run within the same filter type and filter order. Hangfire supports the following types of filters: Client / Server filters, which implement and interfaces respectively. State changing filters, which implement the interface. State changed filters, which implement the interface. Client / Server exception filters, which implement or interfaces respectively. Порядок запуска указанных типов фильтров строго фиксирован, например, фильтры исключений всегда выполняются после всех остальных фильтров, а фильтры состояний всегда запускаются внутри клиентских и серверных фильтров. Внутри же одного типа фильтров, порядок выполнения сначала определяется значением Order, а затем значением Scope. Перечисление определяет следующие значения (в порядке, в котором они будут выполнены): . . . Для примера, клиентский фильтр, у которого свойство Order имеет значение 0, а значение filter scope равно , будет выполнен раньше фильтра с тем же самым значением Order, но c filter scope, равным . Значения Scope задаются, в основном, в реализациях интерфейса . Так, класс определяет значение Scope как . Порядок выполнения фильтров одинакового типа, с одинаковым значением Order и с одинаковым scope, не оговаривается. Specifies an order before the . Specifies an order after the and before the . Specifies an order after the . The exception that is thrown when a job could not be loaded from the storage due to missing or incorrect information about its type or method. Initializes a new instance of the class with a given message and information about inner exception. For internal data using isolated settings that can't be changed from user code. For internal data using isolated settings with types information ( setting) that can't be changed from user code. For user data like arguments and parameters, configurable via . Provides methods to serialize/deserialize data with Hangfire default settings. Isolates internal serialization process from user interference including `JsonConvert.DefaultSettings` modification. Serializes data with option. Use this method to serialize internal data. Using isolated settings that can't be changed from user code. Serializes data with specified option. Use option to serialize internal data. Use option if you need to store type information. Use option to serialize user data like arguments and parameters, configurable via . Serializes data with specified option. Use option to serialize internal data. Use option if you need to store type information. Use option to serialize user data like arguments and parameters, configurable via . Deserializes data with option. Use this method to deserialize internal data. Using isolated settings that can't be changed from user code. Deserializes data with specified option. Use to deserialize internal data. Use if deserializable internal data has type names information. Use to deserialize user data like arguments and parameters, configurable via . Deserializes data with option. Use this method to deserialize internal data. Using isolated settings that can't be changed from user code. Deserializes data with specified option. Use to deserialize internal data. Use if deserializable internal data has type names information. Use to deserialize user data like arguments and parameters, configurable via . The namespace provides base types for background job filters, such as , and some helper classes. Helper class that provides common values for the cron expressions. Returns cron expression that fires every minute. Returns cron expression that fires every hour at the first minute. Returns cron expression that fires every hour at the specified minute. The minute in which the schedule will be activated (0-59). Returns cron expression that fires every day at 00:00 UTC. Returns cron expression that fires every day at the first minute of the specified hour in UTC. The hour in which the schedule will be activated (0-23). Returns cron expression that fires every day at the specified hour and minute in UTC. The hour in which the schedule will be activated (0-23). The minute in which the schedule will be activated (0-59). Returns cron expression that fires every week at Monday, 00:00 UTC. Returns cron expression that fires every week at 00:00 UTC of the specified day of the week. The day of week in which the schedule will be activated. Returns cron expression that fires every week at the first minute of the specified day of week and hour in UTC. The day of week in which the schedule will be activated. The hour in which the schedule will be activated (0-23). Returns cron expression that fires every week at the specified day of week, hour and minute in UTC. The day of week in which the schedule will be activated. The hour in which the schedule will be activated (0-23). The minute in which the schedule will be activated (0-59). Returns cron expression that fires every month at 00:00 UTC of the first day of month. Returns cron expression that fires every month at 00:00 UTC of the specified day of month. The day of month in which the schedule will be activated (1-31). Returns cron expression that fires every month at the first minute of the specified day of month and hour in UTC. The day of month in which the schedule will be activated (1-31). The hour in which the schedule will be activated (0-23). Returns cron expression that fires every month at the specified day of month, hour and minute in UTC. The day of month in which the schedule will be activated (1-31). The hour in which the schedule will be activated (0-23). The minute in which the schedule will be activated (0-59). Returns cron expression that fires every year on Jan, 1st at 00:00 UTC. Returns cron expression that fires every year in the first day at 00:00 UTC of the specified month. The month in which the schedule will be activated (1-12). Returns cron expression that fires every year at 00:00 UTC of the specified month and day of month. The month in which the schedule will be activated (1-12). The day of month in which the schedule will be activated (1-31). Returns cron expression that fires every year at the first minute of the specified month, day and hour in UTC. The month in which the schedule will be activated (1-12). The day of month in which the schedule will be activated (1-31). The hour in which the schedule will be activated (0-23). Returns cron expression that fires every year at the specified month, day, hour and minute in UTC. The month in which the schedule will be activated (1-12). The day of month in which the schedule will be activated (1-31). The hour in which the schedule will be activated (0-23). The minute in which the schedule will be activated (0-59). Returns cron expression that never fires. Specifically 31st of February Returns cron expression that fires every <> minutes. The number of minutes to wait between every activation. Returns cron expression that fires every <> hours. The number of hours to wait between every activation. Returns cron expression that fires every <> days. The number of days to wait between every activation. Returns cron expression that fires every <> months. The number of months to wait between every activation. Converts a Cron expression string into a description. A Cron expression string. English description. The path for the Back To Site link. Set to in order to hide the Back To Site link. The interval the /stats endpoint should be polled with. The Title displayed on the dashboard, optionally modify to describe this dashboards purpose. Display name provider for jobs A strongly-typed resource class, for looking up localized strings, etc. Returns the cached ResourceManager instance used by this class. Overrides the current thread's CurrentUICulture property for all resource lookups using this strongly typed resource class. Looks up a localized string similar to Don't worry, continuations are working as expected. But your current job storage does not support some queries required to show this page. Please try to update your storage or wait until the full command set is implemented.. Looks up a localized string similar to Continuations are working, but this page can't be displayed. Looks up a localized string similar to No jobs found in awaiting state.. Looks up a localized string similar to Options. Looks up a localized string similar to Parent. Looks up a localized string similar to Awaiting Jobs. Looks up a localized string similar to Can not find the target method.. Looks up a localized string similar to Condition. Looks up a localized string similar to Continuations. Looks up a localized string similar to Created. Looks up a localized string similar to Delete. Looks up a localized string similar to Do you really want to DELETE ALL selected jobs?. Looks up a localized string similar to Delete selected. Looks up a localized string similar to Deleting.... Looks up a localized string similar to Disabled. Looks up a localized string similar to Enqueue jobs. Looks up a localized string similar to Enqueued. Looks up a localized string similar to Enqueueing.... Looks up a localized string similar to Error. Looks up a localized string similar to Fetched. Looks up a localized string similar to Id. Looks up a localized string similar to Job. Looks up a localized string similar to Job expired.. Looks up a localized string similar to Job's state has been changed while fetching data.. Looks up a localized string similar to Fewer details.... Looks up a localized string similar to More details.... Looks up a localized string similar to No state. Looks up a localized string similar to N/A. Looks up a localized string similar to Day. Looks up a localized string similar to Week. Looks up a localized string similar to Reason. Looks up a localized string similar to Requeue jobs. Looks up a localized string similar to Retry. Looks up a localized string similar to Server. Looks up a localized string similar to State. Looks up a localized string similar to Unknown. Looks up a localized string similar to No deleted jobs found.. Looks up a localized string similar to Deleted. Looks up a localized string similar to Deleted Jobs. Looks up a localized string similar to The queue is empty.. Looks up a localized string similar to Enqueued jobs. Looks up a localized string similar to <strong>Failed jobs do not become expired</strong> to allow you to re-queue them without any time pressure. You should re-queue or delete them manually, or apply <code>AutomaticRetry(OnAttemptsExceeded = AttemptsExceededAction.Delete)</code> attribute to delete them automatically.. Looks up a localized string similar to You have no failed jobs at the moment.. Looks up a localized string similar to Failed. Looks up a localized string similar to Failed Jobs. Looks up a localized string similar to The queue is empty.. Looks up a localized string similar to Fetched jobs. Looks up a localized string similar to Failed. Looks up a localized string similar to Succeeded. Looks up a localized string similar to History graph. Looks up a localized string similar to Realtime graph. Looks up a localized string similar to Overview. Looks up a localized string similar to Created. Looks up a localized string similar to Do you really want to delete this job?. Looks up a localized string similar to <strong>The job was aborted</strong> – it is processed by server <code>{0}</code> which is not in the <a href="{1}">active servers</a> list for now. It will be retried automatically after invisibility timeout, but you can also re-queue or delete it manually.. Looks up a localized string similar to <strong>Looks like the job was aborted</strong> – it is processed by server <code>{0}</code>, which reported its heartbeat more than 1 minute ago. It will be retried automatically after invisibility timeout, but you can also re-queue or delete it manually.. Looks up a localized string similar to Background job '{0}' has expired or could not be found on the server.. Looks up a localized string similar to <strong>The job is finished</strong>. It will be removed automatically <em><abbr data-moment="{0}">{1}</abbr></em>.. Looks up a localized string similar to Job ID. Looks up a localized string similar to Requeue. Looks up a localized string similar to State. Looks up a localized string similar to Awaiting. Looks up a localized string similar to Deleted. Looks up a localized string similar to Enqueued. Looks up a localized string similar to Failed. Looks up a localized string similar to Processing. Looks up a localized string similar to Scheduled. Looks up a localized string similar to Succeeded. Looks up a localized string similar to Back to site. Looks up a localized string similar to Generated: {0}ms. Looks up a localized string similar to Time:. Looks up a localized string similar to Active Connections. Looks up a localized string similar to Awaiting. Looks up a localized string similar to Deleted Jobs. Looks up a localized string similar to Enqueued. Looks up a localized string similar to Enqueued / Queues. Looks up a localized string similar to {0} failed job(s) found. Retry or delete them manually.. Looks up a localized string similar to Failed Jobs. Looks up a localized string similar to Processing Jobs. Looks up a localized string similar to Recurring Jobs. Looks up a localized string similar to Retries. Looks up a localized string similar to Scheduled Jobs. Looks up a localized string similar to Servers. Looks up a localized string similar to Succeeded Jobs. Looks up a localized string similar to Total Connections. Looks up a localized string similar to Jobs. Looks up a localized string similar to Recurring Jobs. Looks up a localized string similar to Retries. Looks up a localized string similar to Servers. Looks up a localized string similar to Next. Looks up a localized string similar to Prev. Looks up a localized string similar to Total items. Looks up a localized string similar to Items per page. Looks up a localized string similar to Looks like the job was aborted. Looks up a localized string similar to No jobs are being processed right now.. Looks up a localized string similar to Started. Looks up a localized string similar to Processing Jobs. Looks up a localized string similar to No jobs queued.. Looks up a localized string similar to No queued jobs found. Try to enqueue a job.. Looks up a localized string similar to Length. Looks up a localized string similar to Next jobs. Looks up a localized string similar to Queue. Looks up a localized string similar to Queues. Looks up a localized string similar to Canceled. Looks up a localized string similar to No recurring jobs found.. Looks up a localized string similar to Cron expression is invalid or don't have any occurrences over the next 100 years. Looks up a localized string similar to Cron. Looks up a localized string similar to Last execution. Looks up a localized string similar to Next execution. Looks up a localized string similar to Time zone. Looks up a localized string similar to Recurring jobs. Looks up a localized string similar to Triggering.... Looks up a localized string similar to Trigger now. Looks up a localized string similar to All is OK – you have no retries.. Looks up a localized string similar to Retries. Looks up a localized string similar to <h4>Retries are working, but this page can't be displayed</h4> <p> Don't worry, retries are working as expected. Your current job storage does not support some queries required to show this page. Please try to update your storage or wait until the full command set is implemented. </p> <p> Please go to the <a href="{0}">Scheduled jobs</a> page to see all the scheduled jobs including retries. </p>. Looks up a localized string similar to Enqueue now. Looks up a localized string similar to There are no scheduled jobs.. Looks up a localized string similar to Enqueue. Looks up a localized string similar to Scheduled. Looks up a localized string similar to Scheduled Jobs. Looks up a localized string similar to Active. Looks up a localized string similar to There are no active servers. Background tasks will not be processed.. Looks up a localized string similar to Some of the servers don't have heartbeat reported within the last minute and may be aborted. If they don't report heartbeat in the near future, they will be removed automatically after timeout is exceeded, no manual action is required. Incomplete background jobs running on those servers will be re-queued automatically, but you can speed up the process by checking the <a href="{0}">Processing Jobs</a> page.. Looks up a localized string similar to Aborted servers will be removed automatically. Looks up a localized string similar to Possibly aborted. Looks up a localized string similar to Heartbeat. Looks up a localized string similar to Name. Looks up a localized string similar to Queues. Looks up a localized string similar to Started. Looks up a localized string similar to Workers. Looks up a localized string similar to Servers. Looks up a localized string similar to No succeeded jobs found.. Looks up a localized string similar to Succeeded. Looks up a localized string similar to Total Duration. Looks up a localized string similar to Succeeded Jobs. The namespace contains the class, layout for all the Dashboard UI pages. Maps dashboard to the app builder pipeline at "/hangfire" with authorization filter that blocks all remote requests and storage instance. The app builder Maps dashboard to the app builder pipeline at the specified path with authorization filter that blocks all remote requests and storage instance. The app builder The path to map dashboard Maps dashboard to the app builder pipeline at the specified path with authorization filter that blocks all remote requests and storage instance. The app builder The path to map dashboard The application path on Back To Site link. Pass null in order to hide the Back To Site link. Maps dashboard to the app builder pipeline at the specified path with given authorization filters that apply to any request and storage instance. The app builder The path to map dashboard The application path on Back To Site link Array of authorization filters Maps dashboard to the app builder pipeline at the specified path with given authorization filters that apply to any request and storage instance that is used to query the information. The app builder The path to map dashboard The application path on Back To Site link Array of authorization filters The storage instance The namespace contains types that allow you to restrict an access to the Dashboard UI by implementing the interface, as well as customize it by adding new pages, menu items, metrics, routes. These settings is used to serialize user data like arguments or parameters. You can use with option to serialize with specified settings Represents the global filter collection. Gets the global filter collection. Provides methods for creating all the types of background jobs and changing their states. Please see the class for details regarding the implementation. Creates a new background job in a specified state. Job that should be processed in background. Initial state for a background job. Unique identifier of a created background job -or- , if it was not created. is null. is null. Creation failed due to an exception. The interface allows implementations to return value for this method when background job creation has been canceled by an implementation under the normal circumstances (not due to an exception). For example, the class contains the property that may be used by a client filter to cancel a background job creation. The interface allows implementations to create a background job in a state other than specified. The given state instance also may be modified. For example, class contains public setter for the property allowing to choose completely different state by state election filters. Attempts to change a state of a background job with a given identifier to a specified one. Identifier of background job, whose state should be changed. New state for a background job. Expected state assertion, or if unneeded. , if a given state was applied successfully otherwise . is null. is null. State change failed due to an exception. If value is not null, state change will be performed only if the current state name of a job equal to the given value. The interface allows implementations to change a state of a background job to other than specified. The given state instance also may be modified. For example, class contains public setter for the property allowing to choose completely different state by state election filters. If a state was changed, value will be returned. Gets or sets the current instance that will be used to activate jobs during performance. Specifies a display name for a job method. Gets display name for the job. Gets or sets resource type to localize string. Represents a job filter that automatically deletes a background job, when a certain amount of time elapsed since its creation. Deletion is taking place when a attempts to move a job to the state. Initializes a new instance of the class with the given timeout value. Non-negative timeout value in seconds that will be used to determine whether to delete a job. has a negative value. Gets or sets a level for log message that will be produced, when a background job was deleted due to exceeded timeout. Tells bootstrapper to start a job server with default options on application start and stop it automatically on application shutdown request. Global job storage is used. Configuration Tells bootstrapper to start a job server with the given amount of workers on application start and stop it automatically on application shutdown request. Global job storage is used. Configuration Worker count Tells bootstrapper to start a job server with the given queues array on application start and stop it automatically on application shutdown request. Global job storage is used. Configuration Queues to listen Tells bootstrapper to start a job server with the given queues array and specified amount of workers on application start and stop it automatically on application shutdown request. Global job storage is used. Configuration Worker count Queues to listen Tells bootstrapper to start a job server with the given options on application start and stop it automatically on application shutdown request. Global job storage is used. Configuration Job server options Tells bootstrapper to start a job server, that uses the given job storage, on application start and stop it automatically on application shutdown request. Configuration Job storage to use Tells bootstrapper to start a job server with the given options that use the specified storage (not the global one) on application start and stop it automatically on application shutdown request. Configuration Job storage to use Job server options Represents a configuration class for Hangfire components that is used by the class. Tells bootstrapper to pass the given collection of filters to the dashboard middleware to authorize dashboard requests. Previous calls to this method are ignored. Empty array enables access for all users. Authorization filters Tells bootstrapper to register the given job filter globally. Job filter instance Tells bootstrapper to map the dashboard middleware to the given path in the OWIN pipeline. Dashboard path, '/hangfire' by default Tells bootstrapper to use the given path on Back To Site link in the dashboard. Back To Site path, '/' by default Tells bootstrapper to register the given instance of the class globally. Job storage Tells bootstrapper to register the given instance of the class globally. Job storage Tells bootstrapper to start the given job server on application start, and stop it automatically on application shutdown request. Job server Starts the specified background job server and registers the call to its `Dispose` method at OWIN application's shutdown event. The app builder The background job server to start The namespace contains types that are responsible for background processing. You may use them to customize your processing pipeline by implementing the interface or define your own continuously-running background processes by implementing the as well as create completely custom instances of . Responsible for running the given collection background processes. Immediately starts the processes in a background thread. Responsible for announcing/removing a server, bound to a storage. Wraps all the processes with a infinite loop and automatic retry. Executes all the processes in a single context. Uses timeout in dispose method, waits for all the components, cancel signals shutdown Contains some required processes and uses storage processes. Generates unique id. Properties are still bad. Initializes a new instance of the class and immediately starts all the given background processes. Represents a background process responsible for enqueueing delayed jobs. This background process polls the delayed job schedule for delayed jobs that are ready to be enqueued. To prevent a stress load on a job storage, the configurable delay is used between scheduler runs. Delay is used only when there are no more background jobs to be enqueued. When a background job is ready to be enqueued, it is simply moved from to the by using . Delayed job schedule is based on a Set data structure of a job storage, so you can use this background process as an example of a custom extension. Multiple instances of this background process can be used in separate threads/processes without additional configuration (distributed locks are used). However, this only adds support for fail-over, and does not increase the performance. If you are using custom filter providers, you need to pass a custom instance to make this process respect your filters when enqueueing background jobs. Represents a default polling interval for delayed job scheduler. This field is read-only. The value of this field is TimeSpan.FromSeconds(15). Initializes a new instance of the class with the value as a delay between runs. Initializes a new instance of the class with a specified polling interval. Delay between scheduler runs. Initializes a new instance of the class with a specified polling interval and given state changer. Delay between scheduler runs. State changer to use for background jobs. is null. Provides methods for defining processes that will be executed in a background thread by . Needs a wait. Cancellation token Connection disposal Context for a background process. is null. Defines methods that are required for the server exception filter. Called when an exception occurred during the performance of the job. The filter context. Defines methods that are required for a server filter. Called before the performance of the job. The filter context. Called after the performance of the job. The filter context. Provides information about the context in which the job is performed. Gets an instance of the key-value storage. You can use it to pass additional information between different client filters or just between different methods. Provides the context for the method of the interface. Gets a value that was returned by the job. Gets a value that indicates that this object was canceled. Gets an exception that occurred during the performance of the job. Gets or sets a value that indicates that this object handles an exception occurred during the performance of the job. Provides the context for the method of the interface. Gets or sets a value that indicates that this object was canceled. Represents a background process responsible for enqueueing recurring jobs. This background process polls the recurring job schedule for recurring jobs ready to be enqueued. Interval between scheduler polls is hard-coded to 1 minute as a compromise between frequency and additional stress on job storage. Use custom background processes if you need to schedule recurring jobs with frequency less than one minute. Please see the interface for details. Recurring job schedule is based on Set and Hash data structures of a job storage, so you can use this background process as an example of a custom extension. Multiple instances of this background process can be used in separate threads/processes without additional configuration (distributed locks are used). However, this only adds support for fail-over, and does not increase the performance. If you are using custom filter providers, you need to pass a custom instance to make this process respect your filters when enqueueing background jobs. Initializes a new instance of the class with default background job factory. Initializes a new instance of the class with custom background job factory and a state machine. Factory that will be used to create background jobs. is null. Initializes a new instance of the class with custom background job factory, state machine and clocks. Factory that will be used to create background jobs. Delay before another polling attempt, when no jobs scheduled yet. is null. Initializes a new instance of the class with custom background job factory, state machine and clocks. Factory that will be used to create background jobs. Delay before another polling attempt, when no jobs scheduled yet. Function that returns a time zone object by its identifier. is null. is null. Provides the context for the method of the interface. Gets an exception that occurred during the performance of the job. Gets or sets a value that indicates that this object handles an exception occurred during the performance of the job. Represents a background process responsible for processing fire-and-forget jobs. This is the heart of background processing in Hangfire Bootstraps Hangfire components using the given configuration action and maps Hangfire Dashboard to the app builder pipeline at the configured path ('/hangfire' by default). The app builder Configuration action The namespace contains types that describe background job states and the transitions between them. You can implement custom or to customize the state changing pipeline, or define your own state by implementing the interface. Defines the intermediate state of a background job when it is waiting for a parent background job to be finished before it is moved to the by the filter. Background job in is referred as a continuation of a background job with . Represents the name of the Awaiting state. This field is read-only. The value of this field is "Awaiting". Initializes a new instance of the class with the specified parent background job id and with an instance of the class as a next state. The identifier of a background job to wait for. Initializes a new instance of the class with the specified parent job id and next state. The identifier of a background job to wait for. The next state for the continuation. Initializes a new instance of the class with the given options along with other parameters. The identifier of a background job to wait for. The next state for the continuation. Options to configure a continuation. Initializes a new instance of the class with the specified expiration time along with other parameters. The identifier of a background job to wait for. The next state for the continuation. Options to configure the continuation. The expiration time for the continuation. Gets the identifier of a parent background job. Gets the next state, to which a background job will be moved. Gets the continuation options associated with the current state. Gets the expiration time of a background job continuation. Always equals to for the . Please see the remarks section of the IState.Name article for the details. Always returns for the . Please refer to the IState.IsFinal documentation for the details. Always returns for the . Please see the description of this property in the IState.IgnoreJobLoadException article. Returning dictionary contains the following keys. You can obtain the state data by using the method. Key Type Deserialize Method Notes ParentId Not required Please see the property. NextState with Please see the property. Options with Please see the property. Defines the final state of a background job when nobody is interested whether it was performed or not. Deleted state is used when you are not interested in a processing of a background job. This state isn't backed by any background process, so when you change a state of the job to the Deleted, only expiration time will be set on a job without any additional processing. The following example demonstrates how to cancel an enqueued background job. Please note that this job may be processed before you change its state. This example shows how to create an instance of the class and use the method. Please see BackgroundJob.Delete and BackgroundJobClientExtensions.Delete method overloads for simpler API. BackgroundJob.Delete Overload BackgroundJobClientExtensions.Delete Overload Represents the name of the Deleted state. This field is read-only. The value of this field is "Deleted". Initializes a new instance of the class. Always equals to for the . Please see the remarks section of the IState.Name article for the details. Always returns for the . Please refer to the IState.IsFinal documentation for the details. Always returns for the . Please see the description of this property in the IState.IgnoreJobLoadException article. Gets a date/time when the current state instance was created. Returning dictionary contains the following keys. You can obtain the state data by using the method. Key Type Deserialize Method Notes DeletedAt Please see the property. Defines the intermediate state of a background job when it is placed on a message queue to be processed by the background process as soon as possible. Background job in is referred as fire-and-forget job. Background job identifier is placed on a queue with the given name. When a queue name wasn't specified, the name will be used. Message queue implementation depends on a current instance. The following example demonstrates the creation of a background job in . Please see BackgroundJob.Enqueue and BackgroundJobClientExtensions.Enqueue method overloads for simpler API. The code below implements the retry action for a failed background job. BackgroundJob.Enqueue Overload BackgroundJobClientExtensions.Enqueue Overload BackgroundJobClientExtensions.Create Overload Represents the default queue name. This field is constant. The value of this field is "default". Represents the name of the Enqueued state. This field is read-only. The value of this field is "Enqueued". Initializes a new instance of the class with the default queue name. Initializes a new instance of the class with the specified queue name. The queue name to which a background job identifier will be added. The argument is , empty or consist only of white-space characters. The argument is not a valid queue name. Gets or sets a queue name to which a background job identifier will be added. A queue name that consist only of lowercase letters, digits and underscores. Queue name must consist only of lowercase letters, digits and underscores, other characters aren't permitted. Some examples: "critical" (good) "worker_1" (good) "documents queue" (bad, whitespace) "MyQueue" (bad, capital letters) The value specified for a set operation is , empty or consist only of white-space characters. The value specified for a set operation is not a valid queue name. Gets a date/time when the current state instance was created. Always equals to for the . Please see the remarks section of the IState.Name article for the details. Always returns for the . Please refer to the IState.IsFinal documentation for the details. Always returns for the . Please see the description of this property in the IState.IgnoreJobLoadException article. Returning dictionary contains the following keys. You can obtain the state data by using the method. Key Type Deserialize Method Notes EnqueuedAt Please see the property. Queue Not required Please see the property. Defines the intermediate state of a background job when its processing was interrupted by an exception and it is a developer's responsibility to decide what to do with it next. Failed state is used in Hangfire when something went wrong and an exception occurred during the background job processing. The primary reason for this state is to notify the developers that something went wrong. By default background job is moved to the Failed state only after some automatic retries, because the filter is enabled by default. Failed jobs are not expiring and will stay in your current job storage forever, increasing its size until you retry or delete them manually. If you expect some exceptions, please use the following rules. Ignore, move to Succeeded state – use the catch statement in your code without re-throwing the exception. Ignore, move to Deleted state – use the with option. Re-queue a job – use the with option. It is not supposed to use the class in a user code unless you are writing state changing filters or new background processing rules. Represents the name of the Failed state. This field is read-only. The value of this field is "Failed". Initializes a new instace of the class with the given exception. Exception that occurred during the background job processing. The argument is Gets a date/time when the current state instance was created. Gets the exception that occurred during the background job processing. Always equals to for the . Please see the remarks section of the IState.Name article for the details. Always returns for the . Please refer to the IState.IsFinal documentation for the details. Always returns for the . Please see the description of this property in the IState.IgnoreJobLoadException article. Returning dictionary contains the following keys. You can obtain the state data by using the method. Key Type Deserialize Method Notes FailedAt Please see the property. ExceptionType Not required The full name of the current exception type. ExceptionMessage Not required Message that describes the current exception. ExceptionDetails Not required String representation of the current exception. Provides methods that are required for a state changed filter. Called after the specified state was applied to the job within the given transaction. Called when the state with specified state was unapplied from the job within the given transaction. Attempts to change the state of a job, respecting any applicable job filters and state handlers. Null if a constraint has failed, otherwise the final applied state Also ensures that the job data can be loaded for this job Defines methods that are required for a state changing filter. Called when the current state of the job is being changed to the specified candidate state. This state change could be intercepted and the final state could be changed through setting the different state in the context in an implementation of this method. Provides the essential members for describing a background job state. Background job processing in Hangfire is all about moving a background job from one state to another. States are used to clearly decide what to do with a background job. For example, tells Hangfire that a job should be processed by a , and tells Hangfire that a job should be investigated by a developer. Each state have some essential properties like , and a custom ones that are exposed through the method. Serialized data may be used during the processing stage. Hangfire allows you to define custom states to extend the processing pipeline. interface implementation can be used to define additional work for a state transition, and interface implementation can be used to process background jobs in a new state. For example, delayed jobs and their , continuations and their can be simply moved to an extension package. Let's create a new state. Consider you haves background jobs that throw a transient exception from time to time, and you want to simply ignore those exceptions. By default, Hangfire will move a job that throwed an exception to the , however a job in the failed state will live in a Failed jobs page forever, unless we use , delete or retry it manually, because the is not a final state. Our new state will look like a , but we define the state as a final one, letting Hangfire to expire faulted jobs. Please refer to the interface properties to learn about their details. In articles related to and interfaces we'll discuss how to use this new state. Gets the unique name of the state. Unique among other states string, that is ready for ordinal comparisons. The state name is used to differentiate one state from another during the state change process. So all the implemented states should have a unique state name. Please use one-word names that start with a capital letter, in a past tense in English for your state names, for example: Succeeded Enqueued Deleted Failed The returning value should be hard-coded, no modifications of this property should be allowed to a user. Implementors should not add a public setter on this property. Gets the human-readable reason of a state transition. Any string with a reasonable length to fit dashboard elements. The reason is usually displayed in the Dashboard UI to simplify the understanding of a background job lifecycle by providing a human-readable text that explains why a background job is moved to the corresponding state. Here are some examples: Can not change the state to 'Enqueued': target method was not found Exceeded the maximum number of retry attempts The reason value is usually not hard-coded in a state implementation, allowing users to change it when creating an instance of a state through the public setter. Gets if the current state is a final one. for intermediate states, and for the final ones. Final states define a termination stage of a background job processing pipeline. Background jobs in a final state is considered as finished with no further processing required. The state machine marks finished background jobs to be expired within an interval that is defined in the property that is available from a state changing filter that implements the interface. When implementing this property, always hard-code this property to or . Hangfire does not work with states that can be both intermediate and final yet. Don't define a public setter for this property. Gets whether transition to this state should ignore job de-serialization exceptions. to move to the on deserialization exceptions, to ignore them. During a state transition, an instance of the class is deserialized to get state changing filters, and to allow state handlers to perform additional work related to the state. However we cannot always deserialize a job, for example, when job method was removed from the code base or its assembly reference is missing. Since background processing is impossible anyway, the state machine moves such a background job to the in this case to highlight a problem to the developers (because deserialization exception may occur due to bad refactorings or other programming mistakes). However, in some exceptional cases we can ignore deserialization exceptions, and allow a state transition for some states that does not require a instance. itself and are examples of such a behavior. In general, implementers should return when implementing this property. Gets a serialized representation of the current state. Returning dictionary contains the serialized properties of a state. You can obtain the state data by using the method. Please refer to documentation for this method in implementors to learn which key/value pairs are available. A dictionary with serialized properties of the current state. Provides a mechanism for performing custom actions when applying or unapplying the state of a background job by . Gets the name of a state, for which custom actions will be performed. Performs additional actions when applying a state whose name is equal to the property. The context of a state applying process. The current transaction of a state applying process. Performs additional actions when unapplying a state whose name is equal to the property. The context of a state applying process. The current transaction of a state applying process. Provides a mechanism for running state election and state applying processes. Performs the state applying process, where a current background job will be moved to the elected state. The context of a state applying process. Defines the intermediate state of a background job when a has started to process it. Represents the name of the Processing state. This field is read-only. The value of this field is "Processing". Gets a date/time when the current state instance was created. Gets the instance id of an instance of the class, whose background process started to process an enqueued background job. Usually the string representation of a GUID value, may vary in future versions. Gets the identifier of a that started to process an enqueued background job. Always equals to for the . Please see the remarks section of the IState.Name article for the details. Always returns for the . Please refer to the IState.IsFinal documentation for the details. Always returns for the . Please see the description of this property in the IState.IgnoreJobLoadException article. Returning dictionary contains the following keys. You can obtain the state data by using the method. Key Type Deserialize Method Notes StartedAt Please see the property. ServerId Not required Please see the property. WorkerId Not required Please see the property. Defines the intermediate state of a background job when it is placed on a schedule to be moved to the in the future by background process. Background job in is referred as delayed job. The following example demonstrates the creation of a background job that will be processed after two hours. Please see BackgroundJob.Schedule and BackgroundJobClientExtensions.Schedule method overloads for simpler API. BackgroundJob.Schedule Overload BackgroundJobClientExtensions.Schedule Overload Represents the name of the Scheduled state. This field is read-only. The value of this field is "Scheduled". Initializes a new instance of the class with the specified time interval after which a job should be moved to the . The time interval after which a job will be moved to the . Initializes a new instance of the class with the specified date/time in UTC format when a job should be moved to the . The date/time when a job will be moved to the . Gets a date/time when a background job should be enqueued. Any date/time in format. Gets a date/time when the current state instance was created. Always equals to for the . Please see the remarks section of the IState.Name article for the details. Always returns for the . Please refer to the IState.IsFinal documentation for the details. Always returns for the . Please see the description of this property in the IState.IgnoreJobLoadException article. Returning dictionary contains the following keys. You can obtain the state data by using the method. Key Type Deserialize Method Notes EnqueueAt Please see the property. ScheduledAt Please see the property. Defines the final state of a background job when a performed an enqueued job without any exception thrown during the performance. All the transitions to the Succeeded state are internal for the background process. You can't create background jobs using this state, and can't change state to Succeeded. This state is used in a user code primarily in state change filters (TODO: add a link) to add custom logic during state transitions. Represents the name of the Succeeded state. This field is read-only. The value of this field is "Succeeded". Gets a date/time when the current state instance was created. Gets the value returned by a job method. Gets the total number of milliseconds passed from a job creation time till the start of the performance. Gets the total milliseconds elapsed from a processing start. Always equals to for the . Please see the remarks section of the IState.Name article for the details. Always returns for the . Please refer to the IState.IsFinal documentation for the details. Always returns for the . Please see the description of this property in the IState.IgnoreJobLoadException article. Returning dictionary contains the following keys. You can obtain the state data by using the method. Key Type Deserialize Method Notes SucceededAt Please see the property. PerformanceDuration with Please see the property. Latency with Please see the property. Result with argument Please see the property. This key may be missing from the dictionary, when the return value was . Always check for its existence before using it. Represents a custom implementation of the that uses its own threads to execute -based work items and their continuations. The primary purpose of this scheduler is background processing, for other use cases consider using the scheduler instead. You can use this scheduler to offload background tasks to a separate, dedicated pool of threads, instead of executing them in ThreadPool's threads. Background work items don't usually affect the request/response logic directly, so we can afford some additional latency and execute them, when no foreground processing is held. This is useful, when you want to minimize your response latencies to their minimum, and don't want to allow background processing to affect the foreground one. It is not possible to offload *all* the work to dedicated threads, because a lot of libraries hard-code their usage of the default thread pool in one way or another: by using the ConfigureAwait(false) method, by explicitly creating continuations on TaskScheduler.Default, or simply by using ThreadPool.QueueUserWorkItem method. So this is a best-effort attempt. Please note that all unprocessed work items are lost, when the method is called or the corresponding AppDomain is unloaded (for example, due to process shutdown). In order to survive the process restarts, use different solutions with persistence, like Hangfire. Initializes a new instance of the with the number of threads based on the property. All the created threads will be started to dispatch instances scheduled to run on this scheduler. Initializes a new instance of the with the given number of dedicated threads that will be creating using the default thread factory. All the created threads will be started to dispatch instances scheduled to run on this scheduler. The number of dedicated threads will be created. is less or equal to zero. Initializes a new instance of the class with the specified and an optional exception handler. All the created threads will be started to dispatch instances scheduled to run on this scheduler. Callback that creates one or more dedicated threads. Optional callback that is invoked when unhandled exception occurs in one of the threads. After this event this instance is considered stopped. is . returned or zero threads. returned at least one thread not in the state. Signals all the threads to be stopped and releases all the unmanaged resources. This method should be called only when you are uninterested on the corresponding tasks, i.e. during AppDomain unloads, process shutdowns, etc. Indicates that the value of the marked element could be null sometimes, so the check for null is necessary before its usage [CanBeNull] public object Test() { return null; } public void UseTest() { var p = Test(); var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' } Indicates that the value of the marked element could never be null [NotNull] public object Foo() { return null; // Warning: Possible 'null' assignment } Indicates that the marked method builds string by format pattern and (optional) arguments. Parameter, which contains format string, should be given in constructor. The format string should be in -like form [StringFormatMethod("message")] public void ShowError(string message, params object[] args) { /* do something */ } public void Foo() { ShowError("Failed: {0}"); // Warning: Non-existing argument in format string } Specifies which parameter of an annotated method should be treated as format-string Indicates that the function argument should be string literal and match one of the parameters of the caller function. For example, ReSharper annotates the parameter of public void Foo(string param) { if (param == null) throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol } Indicates that the method is contained in a type that implements interface and this method is used to notify that some property value changed The method should be non-static and conform to one of the supported signatures: NotifyChanged(string) NotifyChanged(params string[]) NotifyChanged{T}(Expression{Func{T}}) NotifyChanged{T,U}(Expression{Func{T,U}}) SetProperty{T}(ref T, T, string) public class Foo : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; [NotifyPropertyChangedInvocator] protected virtual void NotifyChanged(string propertyName) { ... } private string _name; public string Name { get { return _name; } set { _name = value; NotifyChanged("LastName"); /* Warning */ } } } Examples of generated notifications: NotifyChanged("Property") NotifyChanged(() => Property) NotifyChanged((VM x) => x.Property) SetProperty(ref myField, value, "Property") Describes dependency between method input and output

Function Definition Table syntax:

FDT ::= FDTRow [;FDTRow]* FDTRow ::= Input => Output | Output <= Input Input ::= ParameterName: Value [, Input]* Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} Value ::= true | false | null | notnull | canbenull If method has single input parameter, it's name could be omitted.
Using halt (or void/nothing, which is the same) for method output means that the methos doesn't return normally.
canbenull annotation is only applicable for output parameters.
You can use multiple [ContractAnnotation] for each FDT row, or use single attribute with rows separated by semicolon.
[ContractAnnotation("=> halt")] public void TerminationMethod() [ContractAnnotation("halt <= condition: false")] public void Assert(bool condition, string text) // regular assertion method [ContractAnnotation("s:null => true")] public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() // A method that returns null if the parameter is null, and not null if the parameter is not null [ContractAnnotation("null => null; notnull => notnull")] public object Transform(object data) [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")] public bool TryParse(string s, out Person result)
Indicates that marked element should be localized or not [LocalizationRequiredAttribute(true)] public class Foo { private string str = "my string"; // Warning: Localizable string } Indicates that the value of the marked type (or its derivatives) cannot be compared using '==' or '!=' operators and Equals() should be used instead. However, using '==' or '!=' for comparison with null is always permitted. [CannotApplyEqualityOperator] class NoEquality { } class UsesNoEquality { public void Test() { var ca1 = new NoEquality(); var ca2 = new NoEquality(); if (ca1 != null) // OK { bool condition = ca1 == ca2; // Warning } } } When applied to a target attribute, specifies a requirement for any type marked with the target attribute to implement or inherit specific type or types. [BaseTypeRequired(typeof(IComponent)] // Specify requirement public class ComponentAttribute : Attribute { } [Component] // ComponentAttribute requires implementing IComponent interface public class MyComponent : IComponent { } Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), so this symbol will not be marked as unused (as well as by other usage inspections) Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes as unused (as well as by other usage inspections) Only entity marked with attribute considered used Indicates implicit assignment to a member Indicates implicit instantiation of a type with fixed constructor signature. That means any unused constructor parameters won't be reported as such. Indicates implicit instantiation of a type Specify what is considered used implicitly when marked with or Members of entity marked with attribute are considered used Entity marked with attribute and all its members considered used This attribute is intended to mark publicly available API which should not be removed and so is treated as used Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. If the parameter is a delegate, indicates that delegate is executed while the method is executed. If the parameter is an enumerable, indicates that it is enumerated while the method is executed Indicates that a method does not make any observable state changes. The same as System.Diagnostics.Contracts.PureAttribute [Pure] private int Multiply(int x, int y) { return x * y; } public void Foo() { const int a = 2, b = 2; Multiply(a, b); // Waring: Return value of pure method is not used } The namespace contains attributes that enable additional code inspections in design time with JetBrains ReSharper. To enable annotations, open ReSharper options → Code Inspections → Code Annotations and add the namespace to the corresponding list. The namespace contains high-level types for configuring, creating and processing background jobs, such as , and . The Hangfire.Storage namespaces contain abstract types like , and for querying and modifying the underlying background job storage. These types are also used to implement support for other persistent storages. The Hangfire.Storage namespaces contain abstract types like , and for querying and modifying the underlying background job storage. These types are also used to implement support for other persistent storages. The provides data transfer objects for the interface. I have no idea why I placed these types to a separate namespace, they should be moved to the parent namespace in version 2.0. Represents attribute, that is used to determine queue name for background jobs. It can be applied to the methods and classes. If the attribute is not applied neither to the method, nor the class, then default queue will be used. (x => x.ReportError("Something bad happened")); // Background job will be placed on the 'critical' queue. BackgroundJob.Enqueue(x => x.ReportFatal("Really bad thing!")); ]]> Initializes a new instance of the class using the specified queue name. Queue name. Gets the queue name that will be used for background jobs. Represents a recurring job manager that allows to create, update or delete recurring jobs. Returns a sequence resulting from applying a function to each element in the source sequence and its predecessor, with the exception of the first element which is only returned as the predecessor of the second element. The type of the elements of . The type of the element of the returned sequence. The source sequence. A transform function to apply to each pair of sequence. Returns the resulting sequence. This operator uses deferred execution and streams its results. int[] numbers = { 123, 456, 789 }; IEnumerable<int> result = numbers.Pairwise(5, (a, b) => a + b); The result variable, when iterated over, will yield 579 and 1245, in turn.