Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalcala committed Jan 8, 2018
1 parent 52b38e2 commit e37b37c
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions README.md
Expand Up @@ -757,7 +757,9 @@ data.StandardError.WriteLine();

### The `AppWorkerBase` class
An implementation of the `IWorker` interface that creates an application service capable of performing some background processing.

[AppWorkerBase API Doc](https://unosquare.github.io/swan/api/Unosquare.Swan.Abstractions.AppWorkerBase.html)

#### Example 1: Inherit from AppWorkerBase
The `AppWorkerBase` class has many methods that can be overwritten such as:

Expand Down Expand Up @@ -798,20 +800,17 @@ The `AppWorkerBase` class has many methods that can be overwritten such as:
}
```
#### Example 2: Using an AppWorker
The `Worker`'s base class also includes properties like:
* **isBusy**: indicates if the thread is busy
* **State**: shows the current state of the app service, based on the AppWorkerState enum (Stopped, Running)
* **CancellationToken**: gets the cancellation token
In this example we use the worker class described above
```csharp
// Create a new AppWorker using the class explained above
var worker = new Worker
{
// Setting an OnExit Action that just prints 'Exited'
OnExit = () =>
{
$"Exited".WriteLine();
}
};
var worker = new Worker();

// Setting an OnExit Action that just prints 'Exited'
worker.OnExit = () =>
{
$"Exited".WriteLine();
};

// Start the worker
worker.Start();

Expand Down

0 comments on commit e37b37c

Please sign in to comment.