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


C# ExecutionState类代码示例

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


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


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