Task Class
- Updated2023-02-21
- 8 minute(s) read
Task Class
Represents a collection of virtual channels and their per-channel properties and timing, triggering, and other properties that apply to the DAQmx Task.
Inheritance Hierarchy
SystemObject
SystemMarshalByRefObject
NationalInstruments.DAQmxTask
SystemMarshalByRefObject
NationalInstruments.DAQmxTask
Namespace: NationalInstruments.DAQmx
Assembly: NationalInstruments.DAQmx (in NationalInstruments.DAQmx.dll) Version: 20.7.40.49302
Syntax
public class Task : MarshalByRefObject, IDisposable, ISynchronizeCallbacks, ISupportSynchronizationContext
Public Class Task Inherits MarshalByRefObject Implements IDisposable, ISynchronizeCallbacks, ISupportSynchronizationContext
The Task type exposes the following members.
Constructors
Name | Description | |
---|---|---|
![]() | Task | Initializes a new instance of the Task class with a unique name. |
![]() | Task(String) | Initializes a new instance of the Task class with the specified name. |
Properties
Name | Description | |
---|---|---|
![]() | AccessoryInsertionOrRemovalDetected | Indicates if any devices in the task detected the insertion or removal of an accessory since the task started. Reading this property clears the accessory change status for all channels in the task. You must read this property before you read DevicesWithInsertedOrRemovedAccessories. Otherwise, you will receive an error. |
![]() | AIChannels | Gets the collection of analog input channels in the task. |
![]() | AOChannels | Gets the collection of analog output channels in the task. |
![]() | CIChannels | Gets the collection of counter input channels in the task. |
![]() | COChannels | Gets the collection of counter output channels in the task. |
![]() | Devices | Indicates an array containing the names of all devices in the task. |
![]() | DevicesWithInsertedOrRemovedAccessories | Indicates the names of any devices that detected the insertion or removal of an accessory since the task started. You must read AccessoryInsertionOrRemovalDetected before you read this property. Otherwise, you will receive an error. |
![]() | DIChannels | Gets the collection of digital input channels in the task. |
![]() | DOChannels | Gets the collection of digital output channels in the task. |
![]() | EveryNSamplesReadEventInterval |
Gets or sets the interval, in number of samples per channel, at which EveryNSamplesRead is called.
|
![]() | EveryNSamplesWrittenEventInterval |
Gets or sets the interval, in number of samples per channel, at which EveryNSamplesWritten is called.
|
![]() | ExportSignals | Gets the exported signal configuration for the task. |
![]() | IsDone | Indicates whether the task completed execution. |
![]() | Stream | Gets the stream for the task. |
![]() | SwitchScan | Gets the switch scan configuration for the task. |
![]() | SynchronizeCallbacks | Specifies how events and callback delegates are invoked.
|
![]() | Timing | Gets the timing configurations for the task. |
![]() | Triggers | Gets the triggers for the task. |
![]() | Watchdog | Gets the watchdog configuration and control object for the task. |
Methods
Name | Description | |
---|---|---|
![]() | AddGlobalChannel | Adds a preconfigured, global channel to the task. |
![]() | ConfigureLogging(String, TdmsLoggingOperation, LoggingMode) | Configures logging to a .tdms file when the acquisition starts.
|
![]() | ConfigureLogging(String, TdmsLoggingOperation, LoggingMode, String) | Configures logging to a .tdms file when the acquisition starts with the specified TDMS channel group name.
|
![]() | Control | Alters the state of the task according to the mode you specify. |
![]() | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) |
![]() | Dispose | Releases all resources used by Task. |
![]() | Dispose(Boolean) |
Releases the managed and unmanaged resources used by Task or optionally releases only the unmanaged resources.
|
![]() | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) |
![]() | OnCounterOutput | Raises the CounterOutput event. |
![]() | OnDigitalChangeDetection | Raises the DigitalChangeDetection event. |
![]() | OnDone | Raises the Done event. |
![]() | OnEveryNSamplesRead | Raises the EveryNSamplesRead event. |
![]() | OnEveryNSamplesWritten | Raises the EveryNSamplesWritten event. |
![]() | OnSampleClock | Raises the SampleClock event. |
![]() | OnSampleComplete | Raises the SampleComplete event. |
![]() | Start | Transitions the task to the running state, which begins the measurement or generation.
|
![]() | StartNewFile | Starts a new TDMS file the next time data is written to disk.
|
![]() | Stop | Transitions the task from the running to the committed state, which ends the measurement or generation.
|
![]() | ToString | Returns a string representation of the object. (Overrides ObjectToString.) |
![]() ![]() | WaitForValidTimestamp(TimestampEvent) | Waits indefinitely until the specified timestampEvent has a value. |
![]() ![]() | WaitForValidTimestamp(TimestampEvent, TimeSpan) | Waits until the specified timestampEvent has a value. |
![]() | WaitUntilDone | Waits for the measurement or generation to complete, regardless of the amount of time needed, and returns if it has completed execution. |
![]() | WaitUntilDone(Int32) | Waits for the measurement or generation to complete and returns if it has completed execution before the specified time elapses. |
![]() | WaitUntilDone(TimeSpan) |
Waits for the measurement or generation to complete and returns if it has completed execution before the specified TimeSpan elapses. |
Events
Name | Description | |
---|---|---|
![]() | CounterOutput | Occurs when any of the counters used in the task reaches its terminal count. |
![]() | DigitalChangeDetection | Occurs when a digital change is detected on any of the digital lines used in the task. |
![]() | Done | Occurs when the task completes. |
![]() | EveryNSamplesRead | Occurs when N number of samples per channel, as defined by EveryNSamplesReadEventInterval, is written from the device to the PC buffer. |
![]() | EveryNSamplesWritten | Occurs when N number of samples per channel, as defined by EveryNSamplesWrittenEventInterval, have been written from the PC buffer to the device. |
![]() | SampleClock | Occurs on each pulse of the task's sample clock. |
![]() | SampleComplete | Occurs when each sample is acquired into the NI-DAQmx driver buffer and is ready for reading. |
Remarks
Task is the principal class that represents the channels, timing, triggering, exported signals, and other information about an NI-DAQmx task. For most tasks, in addition to the Task object, you must create an instance of a reader or writer class to read samples from or write samples to the DaqStream of the task. To create a reader or writer for a particular Task, pass the Stream property of that Task to the reader or writer constructor.
![]() |
---|
Some DAQ devices are not currently supported by the NI-DAQmx driver. Refer to NI-DAQ Readme for a complete listing of supported hardware. |
![]() |
---|
Example applications are located in the Public Documents\National Instruments\NI-DAQ\Examples\DotNET4.x directory or in the Start menu at National InstrumentsNI-DAQmxNI-DAQmx Examples. |
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.