• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ExecutionState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ExecutionState的典型用法代码示例。如果您正苦于以下问题:C# ExecutionState类的具体用法?C# ExecutionState怎么用?C# ExecutionState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExecutionState类属于命名空间,在下文中一共展示了ExecutionState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: StreamWriteAsyncTest

        public async Task StreamWriteAsyncTest()
        {
            byte[] buffer = GetRandomBuffer(1 * 1024 * 1024);
            MemoryStream stream1 = new MemoryStream(buffer);
            MemoryStream stream2 = new MemoryStream();

            OperationContext tempOperationContext = new OperationContext();
            RESTCommand<NullType> cmd = new RESTCommand<NullType>(TestBase.StorageCredentials, null);
            ExecutionState<NullType> tempExecutionState = new ExecutionState<NullType>(cmd, null, tempOperationContext);

            // Test basic write
            await stream1.WriteToAsync(stream2, null, null, false, tempExecutionState, null, CancellationToken.None);
            stream1.Position = 0;

            TestHelper.AssertStreamsAreEqual(stream1, stream2);

            stream2.Dispose();
            stream2 = new MemoryStream();

            await TestHelper.ExpectedExceptionAsync<ArgumentException>(
                async () => await stream1.WriteToAsync(stream2, 1024, 1024, false, tempExecutionState, null, CancellationToken.None),
                "Parameters copyLength and maxLength cannot be passed simultaneously.");

            stream1.Dispose();
            stream2.Dispose();
        }
开发者ID:Gajendra-Bahakar,项目名称:azure-storage-net,代码行数:26,代码来源:WriteToAsyncTests.cs


示例2: Start

        public virtual void Start()
        {
            if (_state != ExecutionState.Created)
            {
                var message = String.Format("Start() called on Fiber with state: {0}", _state);
                throw new ThreadStateException(message);
            }

            _state = ExecutionState.Running;
        }
开发者ID:richwu,项目名称:retlang,代码行数:10,代码来源:BaseFiber.cs


示例3: StreamWriteSyncTestCopyLengthBoundary

        public void StreamWriteSyncTestCopyLengthBoundary()
        {
            byte[] buffer = GetRandomBuffer(1 * 1024 * 1024);
            MemoryStream stream1 = new MemoryStream(buffer);
            MemoryStream stream2 = new MemoryStream();
            MemoryStream stream3 = new MemoryStream();
            
            OperationContext tempOperationContext = new OperationContext();
            RESTCommand<NullType> cmd = new RESTCommand<NullType>(TestBase.StorageCredentials, null);
            ExecutionState<NullType> tempExecutionState = new ExecutionState<NullType>(cmd, null, tempOperationContext);
            
            // Test write with exact number of bytes
            stream1.WriteToSync(stream2, stream1.Length, null, true, false, tempExecutionState, null);
            stream1.Position = 0;
            stream1.WriteToSync(stream3, stream1.Length, null, true, true, tempExecutionState, null);
            stream1.Position = 0;

            TestHelper.AssertStreamsAreEqual(stream1, stream2);
            TestHelper.AssertStreamsAreEqual(stream1, stream3);

            stream2.Dispose();
            stream2 = new MemoryStream();
            stream3.Dispose();
            stream3 = new MemoryStream();

            // Test write with one less byte
            stream1.WriteToSync(stream2, stream1.Length - 1, null, true, false, tempExecutionState, null);
            stream1.Position = 0;
            stream1.WriteToSync(stream3, stream1.Length - 1, null, true, true, tempExecutionState, null);
            stream1.Position = 0;

            Assert.AreEqual(stream1.Length - 1, stream2.Length);
            Assert.AreEqual(stream1.Length - 1, stream3.Length);
            TestHelper.AssertStreamsAreEqualAtIndex(stream1, stream2, 0, 0, (int)stream1.Length - 1);
            TestHelper.AssertStreamsAreEqualAtIndex(stream1, stream3, 0, 0, (int)stream1.Length - 1);

            stream2.Dispose();
            stream2 = new MemoryStream();
            stream3.Dispose();
            stream3 = new MemoryStream();

            // Test with copyLength greater than length
            TestHelper.ExpectedException<ArgumentOutOfRangeException>(
                () => stream1.WriteToSync(stream2, stream1.Length + 1, null, true, false, tempExecutionState, null),
                "The given stream does not contain the requested number of bytes from its given position.");
            stream1.Position = 0;
            TestHelper.ExpectedException<ArgumentOutOfRangeException>(
                () => stream1.WriteToSync(stream3, stream1.Length + 1, null, true, true, tempExecutionState, null),
                "The given stream does not contain the requested number of bytes from its given position.");
            stream1.Position = 0;

            stream1.Dispose();
            stream2.Dispose();
            stream3.Dispose();
        }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:55,代码来源:WriteToSyncTests.cs


示例4: Start

        public void Start()
        {
            // Toggle tthese lines to enable/disable concurrent execution.
            if (taskExecutionState == ExecutionState.Started)
                return;

            taskExecutionState = ExecutionState.Started;
            foreach (var task in tasks)
            {
                task.Execute();
            }
        }
开发者ID:Jusuf,项目名称:Design-Patterns,代码行数:12,代码来源:TaskManager.cs


示例5: OnExecutionStateChanged

		protected virtual void OnExecutionStateChanged(ExecutionState newState){

			if (newState == state) {
				return;
			}

			var oldState = state;
			state = newState;

			var executionStateChanged = ExecutionStateChanged;

			if (executionStateChanged != null) {
				executionStateChanged (this, new ExecutionStateChangedEventArgs (state, oldState));
			}
		}
开发者ID:manuelcosta74,项目名称:opentk,代码行数:15,代码来源:Rendering_ExecutionContext_Android.cs


示例6: WriteToMultiBufferMemoryStreamTestAsync

        public async Task WriteToMultiBufferMemoryStreamTestAsync()
        {
            OperationContext tempOperationContext = new OperationContext();
            RESTCommand<NullType> cmd = new RESTCommand<NullType>(TestBase.StorageCredentials, null);
            ExecutionState<NullType> tempExecutionState = new ExecutionState<NullType>(cmd, null, tempOperationContext);

            byte[] buffer = GetRandomBuffer(1 * 1024 * 1024);
            MemoryStream stream1 = new MemoryStream(buffer);

            MultiBufferMemoryStream stream2 = new MultiBufferMemoryStream(null /* bufferManager */);
            await stream1.WriteToAsync(stream2, null, null, false, tempExecutionState, null, CancellationToken.None);
            stream1.Seek(0, SeekOrigin.Begin);
            stream2.Seek(0, SeekOrigin.Begin);
            TestHelper.AssertStreamsAreEqual(stream1, stream2);

            MultiBufferMemoryStream stream3 = new MultiBufferMemoryStream(null /* bufferManager */);
            await TestHelper.ExpectedExceptionAsync<TimeoutException>(
                () => stream2.FastCopyToAsync(stream3, DateTime.Now.AddMinutes(-1)),
                "Past expiration time should immediately fail");
            stream2.Seek(0, SeekOrigin.Begin);
            stream3.Seek(0, SeekOrigin.Begin);
            await stream2.FastCopyToAsync(stream3, DateTime.Now.AddHours(1));
            stream2.Seek(0, SeekOrigin.Begin);
            stream3.Seek(0, SeekOrigin.Begin);
            TestHelper.AssertStreamsAreEqual(stream2, stream3);

            MultiBufferMemoryStream stream4 = new MultiBufferMemoryStream(null /* bufferManager */, 12345);
            await stream3.FastCopyToAsync(stream4, null);
            stream3.Seek(0, SeekOrigin.Begin);
            stream4.Seek(0, SeekOrigin.Begin);
            TestHelper.AssertStreamsAreEqual(stream3, stream4);

            MemoryStream stream5 = new MemoryStream();
            await stream4.WriteToAsync(stream5, null, null, false, tempExecutionState, null, CancellationToken.None);
            stream4.Seek(0, SeekOrigin.Begin);
            stream5.Seek(0, SeekOrigin.Begin);
            TestHelper.AssertStreamsAreEqual(stream4, stream5);

            TestHelper.AssertStreamsAreEqual(stream1, stream5);
        }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:40,代码来源:MultiBufferMemoryStreamTests.cs


示例7: Fire

        /// <summary>
        /// Invokes the exposed method by name, if successful 
        /// will invoke all nodes connected via the anchor by the same
        /// name.
        /// </summary>
        /// <param name="methodName"></param>
        public void Fire(string methodName, params object[] args)
        {
            try
            {
                foreach(Expose exposed in GetExposed())
                {
                    if(exposed.exposedName == methodName)
                    {
                        FireExposed(exposed);
                    }
                }

            }
            catch(System.Exception exception)
            {
                this.editorExecutionState = ExecutionState.ERROR;

                Debug.LogException(exception);
            }
        }
开发者ID:anneomcl,项目名称:LetsMake,代码行数:26,代码来源:Node.cs


示例8: Execute

        public void Execute()
        {
            try
            {
                this.OnExecute();
            }
            catch(System.Exception exception)
            {
                this.editorExecutionState = ExecutionState.ERROR;

                Debug.LogException(exception);
            }
        }
开发者ID:anneomcl,项目名称:LetsMake,代码行数:13,代码来源:Node.cs


示例9: EditorUpdate

        public void EditorUpdate()
        {
            this.m_editorTimeDelta += Time.deltaTime;

            if(this.m_editorTimeDelta >= this.m_editorStateResetTime)
            {
                this.m_editorTimeDelta = 0;

                if(editorExecutionState != ExecutionState.ERROR)
                {
                    editorExecutionState = ExecutionState.IDLE;
                }
            }

            this.OnShowHideInHierarchy();
            this.OnEditorUpdate();

            foreach(Anchor anchor in anchors)
            {
                anchor.EditorUpdate();
            }
        }
开发者ID:anneomcl,项目名称:LetsMake,代码行数:22,代码来源:Node.cs


示例10: Stop

 public void Stop()
 {
     if (_started != ExecutionState.Running) return; //??just ignore.  why explode?
     lock (_preQueue)
     {
         _started = ExecutionState.Created;
     }
 }
开发者ID:JackWangCUMT,项目名称:Fibrous,代码行数:8,代码来源:FiberBase.cs


示例11: OnRestart

        private void OnRestart (object sender, RoutedEventArgs e)
        {
            this.RunButton.Click -= OnRestart;
            this.RunButton.Content = pausePanel;
            this.RunButton.Click += OnPause;
            execState = ExecutionState.Running;

            this.Dispatcher.Invoke(() =>
            {
                execState = ExecutionState.Running;
                String st;
                _logProcessor.GetFirstLine(out st);
            });
            
            _runTimer.Elapsed += OnTimer;
            _runTimer.Start();
            
           
        }
开发者ID:Lynxa,项目名称:Lambent,代码行数:19,代码来源:SocketWindow.xaml.cs


示例12: StreamWriteAsyncTestMaxLengthBoundary

        public async Task StreamWriteAsyncTestMaxLengthBoundary()
        {
            byte[] buffer = GetRandomBuffer(1 * 1024 * 1024);
            MemoryStream stream1 = new MemoryStream(buffer);
            MemoryStream stream2 = new MemoryStream();

            OperationContext tempOperationContext = new OperationContext();
            RESTCommand<NullType> cmd = new RESTCommand<NullType>(TestBase.StorageCredentials, null);
            ExecutionState<NullType> tempExecutionState = new ExecutionState<NullType>(cmd, null, tempOperationContext);

            // Test write with exact number of bytes
            await stream1.WriteToAsync(stream2, null, stream1.Length, false, tempExecutionState, null, CancellationToken.None);
            stream1.Position = 0;

            TestHelper.AssertStreamsAreEqual(stream1, stream2);

            stream2.Dispose();
            stream2 = new MemoryStream();

            // Test write with one less byte
            await TestHelper.ExpectedExceptionAsync<InvalidOperationException>(
                async () => await stream1.WriteToAsync(stream2, null, stream1.Length - 1, false, tempExecutionState, null, CancellationToken.None),
                "Stream is longer than the allowed length.");
            stream1.Position = 0;

            stream2.Dispose();
            stream2 = new MemoryStream();

            // Test with count greater than length
            await stream1.WriteToAsync(stream2, null, stream1.Length + 1, false, tempExecutionState, null, CancellationToken.None);
            stream1.Position = 0;

            // Entire stream should have been copied
            TestHelper.AssertStreamsAreEqual(stream1, stream2);

            stream1.Dispose();
            stream2.Dispose();
        }
开发者ID:Gajendra-Bahakar,项目名称:azure-storage-net,代码行数:38,代码来源:WriteToAsyncTests.cs


示例13: BenchmarkAlgorithm

 private BenchmarkAlgorithm(BenchmarkAlgorithm original, Cloner cloner) {
   if (original.ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));
   cloner.RegisterClonedObject(original, this);
   name = original.name;
   description = original.description;
   parameters = cloner.Clone(original.parameters);
   readOnlyParameters = null;
   executionState = original.executionState;
   executionTime = original.executionTime;
   storeAlgorithmInEachRun = original.storeAlgorithmInEachRun;
   runsCounter = original.runsCounter;
   Runs = cloner.Clone(original.runs);
   results = cloner.Clone(original.results);
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:14,代码来源:BenchmarkAlgorithm.cs


示例14: BatchRun

 public BatchRun(string name, string description)
   : base(name, description) {
   executionState = ExecutionState.Stopped;
   executionTime = TimeSpan.Zero;
   runsExecutionTime = TimeSpan.Zero;
   repetitions = 10;
   repetitionsCounter = 0;
   Runs = new RunCollection { OptimizerName = Name };
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:9,代码来源:BatchRun.cs


示例15: SetThreadExecutionState

 /// <summary>
 /// Allows an application to inform the system that it 
 /// is in use, thereby preventing the system from entering 
 /// the sleeping power state or turning off the display 
 /// while the application is running.
 /// </summary>
 /// <param name="flags">The thread's execution requirements.</param>
 /// <exception cref="Win32Exception">Thrown if the SetThreadExecutionState call fails.</exception>
 internal static void SetThreadExecutionState(ExecutionState flags)
 {
     ExecutionState? ret = PowerManagementNativeMethods.SetThreadExecutionState(flags);
     if (ret == null)
         throw new Win32Exception("SetThreadExecutionState call failed.");
 }
开发者ID:TanyaTPG,项目名称:Log2Console,代码行数:14,代码来源:Power.cs


示例16: UIElement_OnMouseLeftButtonDown

 private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     var item = (sender as Grid);
     Agent tp = (Agent)item.DataContext;
     if (Keyboard.Modifiers.ToString().Contains("Control"))
     {
         if (tp.ID == _currentAgent)
         {
             this.Dispatcher.Invoke(() =>
             {
                 StatusLabel.Foreground = new SolidColorBrush(Colors.Red);
                 StatusLabel.Content = "This is actually the current agent.";
                 _statusTime = DateTime.Now;
             });
         }
         else if (_logProcessor.IsAgentLogAvailable(tp.ID))
         {
             _currentAgent = tp.ID;
             _logProcessor.CurrentAgent = _currentAgent;
             _previousState = execState;
             execState = ExecutionState.Switching;
         }
         else
         {
             this.Dispatcher.Invoke(() =>
             {
                 StatusLabel.Foreground = new SolidColorBrush(Colors.Red);
                 StatusLabel.Content = "Agent #" + tp.ID + " doesn't have the log file";
                 _statusTime = DateTime.Now;
             });
         }
     }
     else
     {
         tp.IsExpanded = !tp.IsExpanded;
     }
 }
开发者ID:Lynxa,项目名称:Lambent,代码行数:37,代码来源:SocketWindow.xaml.cs


示例17: MainSlider_OnValueChangedSlider_ValueChanged

        private void MainSlider_OnValueChangedSlider_ValueChanged(object sender,
            RoutedPropertyChangedEventArgs<double> e)
        {
            if (execState != ExecutionState.Stopped && (int)MainSlider.Value != _logProcessor.Index)
            {
                double d = MainSlider.Value;
                int tp = (int)d;
                if (tp < _logProcessor.GetAgentStartStep(_currentAgent))
                {
                    tp = _logProcessor.GetAgentStartStep(_currentAgent);
                    //MainSlider.Value = tp;
                }
                else if (tp > LogProcessor.GetAgentEndStep(_currentAgent))
                {
                    tp = LogProcessor.GetAgentEndStep(_currentAgent);
                    //MainSlider.Value = tp;
                }

                Task.Factory.StartNew(() =>
                {

                    lock (_lockerLogProcessorIndex)
                    {
                        if (_logProcessor.GetNumber < tp || tp < 0)
                        {
                            this.Dispatcher.Invoke(() =>
                            {
                                StatusLabel.Foreground = new SolidColorBrush(Colors.Red);
                                StatusLabel.Content = "Illegal step number!";
                                _statusTime = DateTime.Now;
                            });
                            return;
                        }
                        //ast = null;
                        isFirstLine = true;
                        _move_to = tp;
                        if (execState != ExecutionState.Moving)
                        {
                            _previousState = execState;
                            execState = ExecutionState.Moving;
                        }
                    }
                });
            }
        }
开发者ID:Lynxa,项目名称:Lambent,代码行数:45,代码来源:SocketWindow.xaml.cs


示例18: OnStop

        private void OnStop(object sender, RoutedEventArgs e)
        {

            if (execState == ExecutionState.Running)
            {
                this.RunButton.Content = runIcon;
                this.RunButton.Click -= OnPause;
            }
            else if (execState == ExecutionState.Paused)
            {
                this.RunButton.Click -= OnRun;
            }
            this.RunButton.Click += OnRestart;

            if (execState == ExecutionState.Paused || execState == ExecutionState.Running)
            {
                if (execState == ExecutionState.Running)
                {_runTimer.Elapsed -= OnTimer;}

                execState = ExecutionState.Void;
                _runTimer.Stop();

                this.Dispatcher.Invoke(() =>
                {
                    String st;
                    _logProcessor.GetLastLine(out st);
                });
            }
        }
开发者ID:Lynxa,项目名称:Lambent,代码行数:29,代码来源:SocketWindow.xaml.cs


示例19: Dispose

 public virtual void Dispose()
 {
     _state = ExecutionState.Stopped;
     _scheduler.Dispose();
     _subscriptions.Dispose();
 }
开发者ID:richwu,项目名称:retlang,代码行数:6,代码来源:BaseFiber.cs


示例20: Stop

 /// <summary>
 /// Stop consuming actions.
 /// </summary>
 public void Stop()
 {
     _timer.Dispose();
     _started = ExecutionState.Stopped;
     _subscriptions.Dispose();
 }
开发者ID:huangyingwen,项目名称:retlang-1,代码行数:9,代码来源:PoolFiber.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Executor类代码示例发布时间:2022-05-24
下一篇:
C# ExecutionContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap