Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Another Task with same name Exception

I am running my project and got this exception that says "Another task exist with the same name"..There is no other task with this name. I have this task that has 3 AI tasks in it. Why do I get the exception?? Thank you

namespace ProjectGUI
{
using System;
using NationalInstruments.DAQmx;


public class LoadCellTask : Task
{

public LoadCellTask() :
base("LoadCellTask")
{
this.Configure(); //<<<---An error occur here during run saying another task already exist
}

public virtual void Configure()
{
this.AIChannels.CreateVoltageChannel("Dev1/ai4", "Voltage_On_X_Load", AITerminalConfiguration.Differential, -5, 5, AIVoltageUnits.Volts);
this.AIChannels.CreateVoltageChannel("Dev1/ai5", "Voltage_On_Y_Load", AITerminalConfiguration.Differential, -5, 5, AIVoltageUnits.Volts);
this.AIChannels.CreateVoltageChannel("Dev1/ai6", "Voltage_On_Z_Load", AITerminalConfiguration.Differential, -5, 5, AIVoltageUnits.Volts);
this.Timing.ConfigureSampleClock("", 1000, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples);
}
}
}
0 Kudos
Message 1 of 2
(3,012 Views)
This can happen if you don't call Task.Dispose on your task instance and then try to create another instance of the same task class. You might hit this, for example, if you have a button click handler in which you create the task and use it. If you neglect to dispose the task before the button click handler returns, you will get this exception if you click the button again.


This isn't really called out in our conceptual documentation very well; we'll fix that.
0 Kudos
Message 2 of 2
(3,001 Views)