NI-DAQmx .NET Framework 4.0 API Reference

Content Type
Programming Language
Current manual
Table of Contents

Task Class

Task Class

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

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

  NameDescription
Public methodTask
Initializes a new instance of the Task class with a unique name.
Public methodTask(String)
Initializes a new instance of the Task class with the specified name.
Top

Properties

  NameDescription
Public propertyAccessoryInsertionOrRemovalDetected
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.
Public propertyAIChannels
Gets the collection of analog input channels in the task.
Public propertyAOChannels
Gets the collection of analog output channels in the task.
Public propertyCIChannels
Gets the collection of counter input channels in the task.
Public propertyCOChannels
Gets the collection of counter output channels in the task.
Public propertyDevices
Indicates an array containing the names of all devices in the task.
Public propertyDevicesWithInsertedOrRemovedAccessories
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.
Public propertyDIChannels
Gets the collection of digital input channels in the task.
Public propertyDOChannels
Gets the collection of digital output channels in the task.
Public propertyEveryNSamplesReadEventInterval
Gets or sets the interval, in number of samples per channel, at which EveryNSamplesRead is called.
Public propertyEveryNSamplesWrittenEventInterval
Gets or sets the interval, in number of samples per channel, at which EveryNSamplesWritten is called.
Public propertyExportSignals
Gets the exported signal configuration for the task.
Public propertyIsDone
Indicates whether the task completed execution.
Public propertyStream
Gets the stream for the task.
Public propertySwitchScan
Gets the switch scan configuration for the task.
Public propertySynchronizeCallbacks
Specifies how events and callback delegates are invoked.
Public propertyTiming
Gets the timing configurations for the task.
Public propertyTriggers
Gets the triggers for the task.
Public propertyWatchdog
Gets the watchdog configuration and control object for the task.
Top

Methods

  NameDescription
Public methodAddGlobalChannel
Adds a preconfigured, global channel to the task.
Public methodConfigureLogging(String, TdmsLoggingOperation, LoggingMode)
Configures logging to a .tdms file when the acquisition starts.
Public methodConfigureLogging(String, TdmsLoggingOperation, LoggingMode, String)
Configures logging to a .tdms file when the acquisition starts with the specified TDMS channel group name.
Public methodControl
Alters the state of the task according to the mode you specify.
Public methodCreateObjRef
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
Public methodDispose
Releases all resources used by Task.
Protected methodDispose(Boolean)
Releases the managed and unmanaged resources used by Task or optionally releases only the unmanaged resources.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetLifetimeService
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitializeLifetimeService
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodMemberwiseClone(Boolean)
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject.)
Protected methodOnCounterOutput
Raises the CounterOutput event.
Protected methodOnDigitalChangeDetection
Raises the DigitalChangeDetection event.
Protected methodOnDone
Raises the Done event.
Protected methodOnEveryNSamplesRead
Raises the EveryNSamplesRead event.
Protected methodOnEveryNSamplesWritten
Raises the EveryNSamplesWritten event.
Protected methodOnSampleClock
Raises the SampleClock event.
Protected methodOnSampleComplete
Raises the SampleComplete event.
Public methodStart
Transitions the task to the running state, which begins the measurement or generation.
Public methodStartNewFile
Starts a new TDMS file the next time data is written to disk.
Public methodStop
Transitions the task from the running to the committed state, which ends the measurement or generation.
Public methodToString
Returns a string representation of the object.
(Overrides ObjectToString.)
Public methodCode exampleWaitForValidTimestamp(TimestampEvent)
Waits indefinitely until the specified timestampEvent has a value.
Public methodCode exampleWaitForValidTimestamp(TimestampEvent, TimeSpan)
Waits until the specified timestampEvent has a value.
Public methodWaitUntilDone
Waits for the measurement or generation to complete, regardless of the amount of time needed, and returns if it has completed execution.
Public methodWaitUntilDone(Int32)
Waits for the measurement or generation to complete and returns if it has completed execution before the specified time elapses.
Public methodWaitUntilDone(TimeSpan)
Waits for the measurement or generation to complete and returns if it has completed execution before the specified TimeSpan elapses.
Top

Events

  NameDescription
Public eventCounterOutput
Occurs when any of the counters used in the task reaches its terminal count.
Public eventDigitalChangeDetection
Occurs when a digital change is detected on any of the digital lines used in the task.
Public eventDone
Occurs when the task completes.
Public eventEveryNSamplesRead
Occurs when N number of samples per channel, as defined by EveryNSamplesReadEventInterval, is written from the device to the PC buffer.
Public eventEveryNSamplesWritten
Occurs when N number of samples per channel, as defined by EveryNSamplesWrittenEventInterval, have been written from the PC buffer to the device.
Public eventSampleClock
Occurs on each pulse of the task's sample clock.
Public eventSampleComplete
Occurs when each sample is acquired into the NI-DAQmx driver buffer and is ready for reading.
Top

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.
Note Note
Some DAQ devices are not currently supported by the NI-DAQmx driver. Refer to NI-DAQ Readme for a complete listing of supported hardware.
Tip Tip
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.

See Also

Was this information helpful?