Task Constructor

<< 点击显示目录 >>

主页  PVI通信 > PVI帮助信息 > PVI Services > BR.AN.Namespace > BR.AN.PviServices > Task Class > Task Constructor >

Task Constructor

BR.AN.PviServices .NET


Initializes a new instance of the Task class.

[Visual Basic]

Public Overloads Sub New( _

  ByVal cpu As Cpu, _

  ByVal name As String _

)

[C#]

Task(

  Cpu cpu,

  string name

);

Parameters

cpu

Cpu-object (parent)

name

task name

Remarks

This instance will be automatically added to cpus task collection. For this reason its necessary to check the cpus task collection for already existing objects.

Exceptions

Exception Type

Condition

ArgumentException

Task object already exists.

Example

// CPU already connected
// Getting task list from the plc
cpu.Tasks.Upload();
cpu.Tasks.Uploaded += new PviEventHandler(Tasks_Uploaded);
...
...
private void Tasks_Uploaded(object sender, PviEventArgs e)
{
    Task myTask=null;
    // Creating new task "ab_task" and get connected to it
    if ( cpu.Tasks.ContainsKey("ab_task") )
        myTask = cpu.Tasks["ab_task"];        // Task already exists
    else
        myTask = new Task(cpu,"ab_task");    // Task not exist -> create
    myTask.Connect();
}

See Also

Task Class | BR.AN.PviServices Namespace | Task Constructor Overload List


Generated from assembly BR.AN.PviServices [8.1.0.4]