# OpcTaskSchedule Members

> Reference: Defines the central entry point used to schedule any kind of task to perform using custom queuing and scheduling mechanisms.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcTaskSchedule</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx">Opc.UaFx</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

## Properties

### CustomScheduler

<span class="api-meta">static · since v2.11</span>

Gets or sets the callback used to schedule task invocations.

<div class="api-signature" data-lang="csharp">

```csharp
public static OpcTaskSchedule.Scheduler CustomScheduler { get; set; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Property CustomScheduler As OpcTaskSchedule.Scheduler
```

</div>

**Property value**

[OpcTaskSchedule.Scheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule.scheduler/)

A [OpcTaskSchedule.Scheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule.scheduler/) which is used to schedule task invocations, or a null reference (Nothing in Visual Basic) to use a default scheduler. The default value is a null reference (Nothing in Visual Basic).

### DefaultScheduler

<span class="api-meta api-meta--obsolete">static · Obsolete: Use CustomScheduler instead.</span>

Gets or sets the callback used to schedule task invocations. This property is obsolete, use [CustomScheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule/members#customscheduler) instead.

<div class="api-signature" data-lang="csharp">

```csharp
public static OpcTaskSchedule.Scheduler DefaultScheduler { get; set; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
<Obsolete("Use CustomScheduler instead.")>
Public Shared Property DefaultScheduler As OpcTaskSchedule.Scheduler
```

</div>

**Property value**

[OpcTaskSchedule.Scheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule.scheduler/)

The [CustomScheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule/members#customscheduler), or a scheduler which runs each invocation on the thread pool if no [CustomScheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule/members#customscheduler) is set. Setting the value sets the [CustomScheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule/members#customscheduler).

## Methods

### QueryScheduler

<span class="api-meta">static · since v2.11</span>

Determines the [OpcTaskSchedule.Scheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule.scheduler/) to use to schedule task invocations with respect to the `context` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public static OpcTaskSchedule.Scheduler QueryScheduler(
    SynchronizationContext context,
    out bool isContextSensitive)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Function QueryScheduler(
    context As SynchronizationContext,
    isContextSensitive As Boolean) As OpcTaskSchedule.Scheduler
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `context` | [SynchronizationContext](https://learn.microsoft.com/dotnet/api/system.threading.synchronizationcontext) | The [SynchronizationContext](https://learn.microsoft.com/dotnet/api/system.threading.synchronizationcontext) to post the invocations to, or a null reference (Nothing in Visual Basic). |
| `isContextSensitive` | out [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) | When this method returns, the value true if the returned scheduler posts the invocations to the `context`; otherwise the value false. |

**Returns**

[OpcTaskSchedule.Scheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule.scheduler/)

The [CustomScheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule/members#customscheduler) if it is set; otherwise a scheduler which posts each invocation to the `context` if it is not a null reference (Nothing in Visual Basic); otherwise a scheduler which runs each invocation on the thread pool.

### Schedule

<span class="api-meta">static · 2 overloads</span>

| Overload | Description |
|---|---|
| [Schedule(Action)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule/members#schedule-system-action)<span class="api-meta">static</span> | Schedules the invocation of the `action` specified using custom queuing and scheduling mechanisms. |
| [Schedule(Action, SynchronizationContext)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule/members#schedule-system-action-system-threading-synchronizationcontext)<span class="api-meta">static · since v2.11</span> | Schedules the invocation of the `action` specified using custom queuing and scheduling mechanisms. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `action` is a null reference (Nothing in Visual Basic). |

#### Schedule(Action)

<span class="api-meta">static</span>

Schedules the invocation of the `action` specified using custom queuing and scheduling mechanisms.

<div class="api-signature" data-lang="csharp">

```csharp
public static void Schedule(Action action)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Sub Schedule(action As Action)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `action` | [Action](https://learn.microsoft.com/dotnet/api/system.action) | The [Action](https://learn.microsoft.com/dotnet/api/system.action) its invocation is to be scheduled. |

#### Schedule(Action, SynchronizationContext)

<span class="api-meta">static · since v2.11</span>

Schedules the invocation of the `action` specified using custom queuing and scheduling mechanisms.

<div class="api-signature" data-lang="csharp">

```csharp
public static void Schedule(Action action, SynchronizationContext context)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Shared Sub Schedule(action As Action, context As SynchronizationContext)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `action` | [Action](https://learn.microsoft.com/dotnet/api/system.action) | The [Action](https://learn.microsoft.com/dotnet/api/system.action) its invocation is to be scheduled. |
| `context` | [SynchronizationContext](https://learn.microsoft.com/dotnet/api/system.threading.synchronizationcontext) | The [SynchronizationContext](https://learn.microsoft.com/dotnet/api/system.threading.synchronizationcontext) to post the invocation to, or a null reference (Nothing in Visual Basic) (see [QueryScheduler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctaskschedule/members#queryscheduler)). |
