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


C# Task.Stop方法代码示例

本文整理汇总了C#中Task.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# Task.Stop方法的具体用法?C# Task.Stop怎么用?C# Task.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Task的用法示例。


在下文中一共展示了Task.Stop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: TerminateTask

 /// <summary> 
 /// ��ֹһ������ 
 /// </summary> 
 /// <param name="task"></param> 
 public void TerminateTask(Task task)
 {
     task.Stop();
 }
开发者ID:dalinhuang,项目名称:videospstandalonenew,代码行数:8,代码来源:TaskCenter.cs

示例3: startButton_Click

        private static void startButton_Click()
        {
            try
            {
                // Get task from combox box and initialize the analog writer

                counterTask = DaqSystem.Local.LoadTask(taskName);
                int recv;
                byte[] data = new byte[1024];

                IPEndPoint ip = new IPEndPoint(IPAddress.Any, 60011);
                Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

                newsock.Bind(ip);
                IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
                EndPoint Remote = (EndPoint)(sender);

                for (int i = 0; i < 10000000; i++)
                {

                    //System.Threading.Thread.Sleep(5000);

                    recv = newsock.ReceiveFrom(data, ref Remote);

                    counterTask.Start();
                    System.Threading.Thread.Sleep(500);
                    counterTask.Stop();

                    //UdpClient udpClient = new UdpClient(11001);
                    //udpClient.Connect("localhost", 60006);
                    //Byte[] sendBytes = Encoding.ASCII.GetBytes("conveyor success");
                    //int sentLength = udpClient.Send(sendBytes, sendBytes.Length);
                    //if (sentLength > 0) udpClient.Close();
                    System.Console.WriteLine("loop " + i);
                }

                //coWriter = new CounterSingleChannelWriter(counterTask.Stream);
                //counterTask.Control(TaskAction.Verify);
                //coWriter.WriteSingleSample(true,new CODataFrequency(1,0.001));

                //continuousTask.Control(TaskAction.Verify);

                // Generate the sine wave data
                //SignalGenerator fgen = null;
                //fgen = new SignalGenerator(continuousTask.Timing.SampleClockRate, continuousTask.Timing.SamplesPerChannel, new SineSignal());
                //double[] generatedData = fgen.Generate();

                // Convert the generated data to an AnalogWaveform
                //                AnalogWaveform<double> data = AnalogWaveform<double>.FromArray1D(generatedData);

                // Write and plot the generated data
                //WaveformPlot plot = new WaveformPlot();
                //globalContinuousAOWaveformGraph.Plots.Add(plot);

                //writer.WriteWaveform<double>(true, data);
                //globalContinuousAOWaveformGraph.PlotWaveform<double>(data);
                //channelLegend.Items.Add(new LegendItem(plot, continuousTask.AOChannels[0].VirtualName + ": " + continuousTask.AOChannels[0].PhysicalName));

                //stopButton.Enabled = true;
                //taskComboBox.Enabled = false;
            }
            catch (DaqException ex)
            {

            }
        }
开发者ID:psweeney-YU,项目名称:NEVP-conveyor,代码行数:66,代码来源:MainForm.cs

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