当前位置: 首页>>代码示例>>C#>>正文


C# Task.WaitUntilDone方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:rzellertownson,项目名称:neurorighter,代码行数:44,代码来源:ZeroOutput.cs

示例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);
         }
     }
 }
开发者ID:rzellertownson,项目名称:neurorighter,代码行数:31,代码来源:ZeroOutput.cs


注:本文中的Task.WaitUntilDone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。