Show / Hide Table of Contents

Class BackgroundThread

Base class for easier creation and clean cancellation of a background thread.

Inheritance
System.Object
BackgroundThread
RfbMessageReceiver
RfbMessageSender
Implements
IBackgroundThread
IDisposable
Namespace: MarcusW.VncClient.Utils
Assembly: MarcusW.VncClient.dll
Syntax
public abstract class BackgroundThread : object, IBackgroundThread, IDisposable

Constructors

| Improve this Doc View Source

BackgroundThread(String)

Initializes a new instance of the BackgroundThread.

Declaration
protected BackgroundThread(string name)
Parameters
Type Name Description
System.String name

The thread name.

Methods

| Improve this Doc View Source

Dispose()

Declaration
public void Dispose()
| Improve this Doc View Source

Dispose(Boolean)

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
System.Boolean disposing
| Improve this Doc View Source

Start()

Starts the thread.

Declaration
protected void Start()
Remarks

The thread can only be started once.

| Improve this Doc View Source

StopAndWaitAsync()

Stops the thread and waits for completion.

Declaration
protected Task StopAndWaitAsync()
Returns
Type Description
Task
Remarks

It is safe to call this method multiple times.

| Improve this Doc View Source

ThreadWorker(CancellationToken)

Executes the work that should happen in the background.

Declaration
protected abstract void ThreadWorker(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken

The cancellation token that tells the method implementation when to complete.

Events

| Improve this Doc View Source

Failed

Occurs when the background thread fails.

Declaration
public event EventHandler<BackgroundThreadFailedEventArgs>? Failed
Event Type
Type Description
System.Nullable<EventHandler<BackgroundThreadFailedEventArgs>>

Implements

IBackgroundThread
IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX