Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

learning to use TaskDoneEventHandlier with .NET

Hello,

 

 

 

I'm having some difficulty closing (DIsposing) the task, to the extent that I cannot call my routine again.  I receive the "NI Platform Services, this resource could not be allocated" message.  I've tried to mimic the "GenMultiVoltUpdates_IntCLK" example without luck (i.e it doesn't deallocate the resource)..  Basically, the task does not get disposed.  What can I do to correct this?

 

My code is attached (its really quite short).  Assume that the double[,] array "waveform" was previously successfully created.  Basically, it always works the very first time but never on successive calls.  I sorely need help on the TaskEvent handler and Task.Dispose aspects.

 

 Please advise.  Thanks.  Anand

 

0 Kudos
Message 1 of 3
(3,101 Views)

Hi All,

 

It appears that the TaskDoneEventHandlier is not being invoked.

 

Since I'm calling it from within a function that I wrote (not a buttonClick routine),  is there a chance that its not receiving the right arguments (object sender, Evnetargs e) ?

 

If I could receive some assitance with this, I'll be really grateful.  I've yet to master events and delegates in C#.

 

Thanks

 

Anand

0 Kudos
Message 2 of 3
(3,084 Views)

Hi All,

 

Instead of depending upon the TaskDoneEventHandler facility, it is also possible to poll the task in the following manner.

 

- - - - setup waveform

- - - - setup AnalogMultiChannelWriter

- - - - setup Sample Clock

 

myTask.Start();    // outputs waveform on multiple channels clocked by 'onBoardClock'.

while(! myTask.IsDone)    // wait till task completes

{  ;  }    // do nothing

myTask.Dispose();

 

This works fine and does not depend upon the TaskDoneEventHandler.

 

Anand

0 Kudos
Message 3 of 3
(3,078 Views)