本文整理汇总了C#中Task.WaitUntilDone方法的典型用法代码示例。如果您正苦于以下问题:C# Task.WaitUntilDone方法的具体用法?C# Task.WaitUntilDone怎么用?C# Task.WaitUntilDone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task.WaitUntilDone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ZeroAOChanOnDev
internal void ZeroAOChanOnDev(string dev, int[] channelsToZero)
{
lock (this)
{
try
{
// Create an analog out task for a given device for all 4 channels.
// Write clearingBufferSize zeros to that port. Wait
// until this is finished and destroy the clearning Task.
Task analogClearingTask = new Task("AnalogClear");
foreach (int chan in channelsToZero)
analogClearingTask.AOChannels.CreateVoltageChannel(
"/" + dev + "/ao" + chan, "", -10.0, 10.0, AOVoltageUnits.Volts);
//analogClearingTask.Timing.ConfigureSampleClock("/" + dev + "/PF",
// clearingSampleRate,
// SampleClockActiveEdge.Rising,
// SampleQuantityMode.FiniteSamples,
// clearingBufferSize);
analogClearingTask.Timing.ReferenceClockSource = ("/" + dev + "/PFI2");
analogClearingTask.Timing.ReferenceClockRate = 10e6;
AnalogMultiChannelWriter analogClearingWriter = new
AnalogMultiChannelWriter(analogClearingTask.Stream);
double[] zeroData = new double[channelsToZero.Length];
analogClearingWriter.BeginWriteSingleSample(false, zeroData, null, null);
analogClearingTask.Control(TaskAction.Verify);
analogClearingTask.Start();
//analogClearingWriter.WriteSingleSample(true, zeroData);
//analogClearingWriter.WriteMultiSample(true, zeroData);
analogClearingTask.WaitUntilDone(30);
analogClearingTask.Stop();
analogClearingTask.Dispose();
analogClearingTask = null;
}
catch (Exception e)
{
Console.WriteLine("Could not zero analog outputs on device: " + dev);
Console.WriteLine(e.Message);
}
}
}
示例2: ZeroPortOnDev
internal void ZeroPortOnDev(string dev, int port)
{
lock (this)
{
try
{
// Create a digital out task for a given device and port.
// Write clearingBufferSize zeros to that port. Wait
// until this is finished and destroy the clearning Task.
Task digitalClearingTask = new Task("DigiClear");
digitalClearingTask.DOChannels.CreateChannel("/" + dev + "/Port" + port, "",
ChannelLineGrouping.OneChannelForAllLines);
//digitalClearingTask.Timing.ConfigureSampleClock("100KHzTimeBase",
// clearingSampleRate,
// SampleClockActiveEdge.Rising,
// SampleQuantityMode.FiniteSamples,
// clearingBufferSize);
DigitalSingleChannelWriter digitalClearingWriter = new DigitalSingleChannelWriter(digitalClearingTask.Stream);
digitalClearingWriter.BeginWriteSingleSamplePort(true,0,null,null);
digitalClearingTask.WaitUntilDone(30);
digitalClearingTask.Stop();
digitalClearingTask.Dispose();
digitalClearingTask = null;
}
catch (Exception e)
{
Console.WriteLine(" Could not zero digital output on device: "
+ dev + "/" + port);
}
}
}