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


C# ThreadState类代码示例

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


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

示例1: AwaitState

 /// <summary>
 /// Waits for all incoming threads to be in wait()
 ///  methods.
 /// </summary>
 public static void AwaitState(ThreadState state, params ThreadClass[] threads)
 {
     while (true)
     {
         bool done = true;
         foreach (ThreadClass thread in threads)
         {
             if (thread.State != state)
             {
                 done = false;
                 break;
             }
         }
         if (done)
         {
             return;
         }
         if (Random().NextBoolean())
         {
             [email protected]();
         }
         else
         {
             Thread.Sleep(1);
         }
     }
 }
开发者ID:WakeflyCBass,项目名称:lucenenet,代码行数:31,代码来源:TestDocumentsWriterStallControl.cs

示例2: btnPause_Click

 private void btnPause_Click(object sender, EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     if (state == ThreadState.Running) // Press Pause Button's
     {
         if (Algorithm.Algorithm.GetInstance().Pause())
         {
             state = ThreadState.Suspended;
             btnStart.Enabled = true;
             btnPause.Enabled = false;
             btnPause.Text = "&Pause";
             btnStop.Enabled = true;
             btnStart.Text = "&Resume";
             if (ResultForm._setting.AutoSave_OnStopped)
             {
                 Save(Algorithm.Algorithm.GetInstance().GetBestChromosome());
             }
         }
     }
     else if (state == ThreadState.Stopped || state == ThreadState.Aborted) // Press Sava Button's
     {
         Save(Algorithm.Algorithm.GetInstance().GetBestChromosome());
         btnStart.Enabled = true;
         btnPause.Enabled = false;
         btnPause.Text = "&Pause";
         btnStop.Enabled = false;
     }
     this.Cursor = Cursors.Default;
 }
开发者ID:Behzadkhosravifar,项目名称:MakeClassSchedule,代码行数:29,代码来源:ResultForm.cs

示例3: Thread

 public Thread(Closure closure, int stackSize)
 {
     ThreadClosure = closure;
     State = new ThreadState(stackSize);
     State.CurrentInstruction = new InstructionPointer(closure.Func, closure.ClosedVars, 0);
     State.CurrentInstruction.InstructionIndex = -1;
 }
开发者ID:stroan,项目名称:Lamn,代码行数:7,代码来源:Thread.cs

示例4: CanComplete

 public override bool CanComplete(ThreadState threadState)
 {
     // A DelayedUnlock can be completed even if the thread does not
     // own the lock, then the execution does not affect anything
     // except that the instruction acts as a barrier preventing
     // instruction before to be completed after the unlock
     return true;
 }
开发者ID:edwardt,项目名称:study,代码行数:8,代码来源:DelayedUnlock.cs

示例5: _1_SimplifyThreadState

        public static ThreadState _1_SimplifyThreadState(ThreadState ts)
		{
            // Technique to convert threadstate to one of the 4 most useful values:
            // Unstarted, Running, WaitSleepJoin, and Stopped
            return ts & (ThreadState.Unstarted | 
				         ThreadState.WaitSleepJoin | 
						 ThreadState.Stopped);
        }
开发者ID:rpattabi,项目名称:.NETThreading,代码行数:8,代码来源:Program.cs

示例6: TimedAction

        private readonly ThreadState _threadState; // State of the thread

        #endregion Fields

        #region Constructors

        /// <summary> Constructor. </summary>
        /// <param name="interval"> The execution interval. </param>
        /// <param name="action">   The action to execute. </param>
        public TimedAction(double interval, Action action)
        {
            _action = action;
            _threadState = new ThreadState {IsRunning = false};

            _actionTimer = new Timer(interval) {Enabled = false, SynchronizingObject = null};
            _actionTimer.Elapsed += OnActionTimer;
        }
开发者ID:c37-cae,项目名称:T-Bone,代码行数:17,代码来源:TimedAction.cs

示例7: TimedAction

        private readonly ThreadState _threadState; // State of the thread

        #endregion Fields

        #region Constructors

        /// <summary> Constructor. </summary>
        /// <param name="disposeStack">Dispose stack to add itself to</param>
        /// <param name="interval"> The execution interval. </param>
        /// <param name="action">   The action to execute. </param>
        public TimedAction(DisposeStack disposeStack, double interval, Action action)
        {
            disposeStack.Push(this);
            _action = action;
            _threadState = new ThreadState {IsRunning = false};

            _actionTimer = new Timer(interval) {Enabled = false, SynchronizingObject = null};
            _actionTimer.Elapsed += OnActionTimer;
        }
开发者ID:KyleTheHack3r,项目名称:infrared-tv-control,代码行数:19,代码来源:TimedAction.cs

示例8: CanComplete

        public override bool CanComplete(ThreadState threadState)
        {
            // TODO: (much later) support exception here
            VMValue_objectinst vinst = (VMValue_objectinst)threadState.GetValue(obj);
            if(vinst.HoldingLockThreadID != threadState.ThreadID)
                throw new Exception("Calling pulse on a lock we don't possess");

            return true;
        }
开发者ID:edwardt,项目名称:study,代码行数:9,代码来源:DelayedPulse.cs

示例9: ThreadTraceInfo

 public ThreadTraceInfo(int id, string name, DateTime start, float cpuUsage, TimeSpan totalCpuUsageTime, ThreadState state)
 {
     _id = id;
     _name = name;
     _start = start;
     _cpuUsage = cpuUsage;
     _totalCpuUsageTime = totalCpuUsageTime;
     _state = state;
 }
开发者ID:kazuki,项目名称:p2pncs,代码行数:9,代码来源:ThreadTraceInfo.cs

示例10: ThreadSurrogated

 public ThreadSurrogated(Thread thread)
 {
     Id = thread.ManagedThreadId;
     Name = thread.Name;
     Priority = thread.Priority;
     State = thread.ThreadState;
     IsBackground = thread.IsBackground;
     IsThreadPoolThread = thread.IsThreadPoolThread;
 }
开发者ID:jbowwww,项目名称:JDBG,代码行数:9,代码来源:ThreadSurrogated.cs

示例11: Start

        public void Start(Action<Exception> threadFailedHandler)
        {
            if (threadFailedHandler != null)
                ThreadFailed += threadFailedHandler;

            StartCore();

            m_State = ThreadState.Starting;
            m_Thread.Start();
        }
开发者ID:eleks,项目名称:FloatingQueuePoC,代码行数:10,代码来源:ThreadBase.cs

示例12: SmartThread

        /// <summary>
        /// 创建线程
        /// </summary>
        /// <param name="name"></param>
        /// <param name="task"></param>
        /// <param name="isBackground"></param>
        /// <param name="apartmentState"></param>
        public SmartThread(Action task, string name = null, bool isBackground = true, ApartmentState apartmentState = ApartmentState.MTA)
        {
            if (task == null)
                throw new ArgumentNullException("task");

            InnerThread = new System.Threading.Thread(()=>task()) { Name = name, IsBackground = isBackground };
            InnerThread.SetApartmentState(apartmentState);

            mutex = new ResetEvent(false);
            State = ThreadState.NotStarted;
        }
开发者ID:netcasewqs,项目名称:nlite,代码行数:18,代码来源:Thread.cs

示例13: CanComplete

 // A lock action can be completed if the lock is free
 // or it is currently hold by the same thread
 public override bool CanComplete(ThreadState threadState)
 {
     // A DelayedLock can only be completed if the object instance is not locked
     // or it is already locked by this thread
     VMValue_objectinst vinst = (VMValue_objectinst)threadState.GetValue(obj);
     if((vinst.HoldingLockThreadID == threadState.ThreadID) ||
         (vinst.HoldingLockThreadID == -1))
         return true;
     else
         return false;
 }
开发者ID:edwardt,项目名称:study,代码行数:13,代码来源:DelayedLock.cs

示例14: DocumentsWriterPerThreadPool

 /// <summary>
 /// Creates a new <seealso cref="DocumentsWriterPerThreadPool"/> with a given maximum of <seealso cref="ThreadState"/>s.
 /// </summary>
 public DocumentsWriterPerThreadPool(int maxNumThreadStates)
 {
     if (maxNumThreadStates < 1)
     {
         throw new System.ArgumentException("maxNumThreadStates must be >= 1 but was: " + maxNumThreadStates);
     }
     ThreadStates = new ThreadState[maxNumThreadStates];
     NumThreadStatesActive = 0;
     for (int i = 0; i < ThreadStates.Length; i++)
     {
         ThreadStates[i] = new ThreadState(null);
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:16,代码来源:DocumentsWriterPerThreadPool.cs

示例15: executeScript

 /// <summary>
 /// Start executing the robotscript
 /// </summary>
 public void executeScript()
 {
     try
     {
         thread = new Thread(new ThreadStart(scriptexecutor));
         thState = thread.ThreadState;
         thread.Start();
     }
     catch (ThreadStateException)
     {
         return;
     }
 }
开发者ID:expeehaa,项目名称:Robotersteuerung,代码行数:16,代码来源:ScriptExecutor.cs


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