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

C# ThreadState类代码示例

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

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



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


示例16: Mission

 private Mission(eTaskType taskType, string missionName, string dllLocation, string className, string launchMethod,
     string shutDownMethod, int launchInterval, int _errorTryInterval, eMissionStatus missionStatus)
 {
     _TaskType = taskType;
     _MissionName = missionName;
     _DllLocation = string.Format(@"{0}{1}", System.AppDomain.CurrentDomain.BaseDirectory, dllLocation); ;
     _ClassName = className;
     _LaunchMethod = launchMethod;
     _ShutDownMethod = shutDownMethod;
     _LaunchInterval = launchInterval;
     _ErrorTryInterval = _errorTryInterval;
     _MissionStatus = missionStatus;
     _MissionOwnerStatus = ThreadState.Unstarted;
 }
开发者ID:robertoye,项目名称:StrongDispatcher,代码行数:14,代码来源:Mission.cs


示例17: ThreadStateAsString

        private static string ThreadStateAsString(ThreadState state)
        {
            var values = (ThreadState[])Enum.GetValues(typeof(ThreadState));
            var extractedValues = new List<string>();

            foreach (var value in values)
            {
                if ((state & value) == value)
                {
                    extractedValues.Add(DebuggerBase.Instance.MuiProcessor.GetString(_threadStateMuiIdentifiers[value]));
                }
            }

            return string.Join(", ", extractedValues);
        }
开发者ID:die-Deutsche-Orthopaedie,项目名称:LiteDevelop,代码行数:15,代码来源:ThreadsControl.cs


示例18: Complete

 // In completion stage, the lock action will actually
 // set the object's lock field to be locked by this thread
 public override void Complete(ThreadState threadState)
 {
     VMValue_objectinst vinst = (VMValue_objectinst)threadState.GetValue(obj);
     if(vinst.HoldingLockThreadID == -1)
     {
         vinst.HoldingLockThreadID = threadState.ThreadID;
         vinst.HoldingLockCount = nTimes;
     }
     else
         vinst.HoldingLockCount += nTimes;
     if(CheckerConfiguration.DoPrintExecution)
     {
         Console.WriteLine("Commiting Lock in thread " + threadState.CurrentMethod.Name + " on " + obj);
     }
 }
开发者ID:edwardt,项目名称:study,代码行数:17,代码来源:DelayedLock.cs


示例19: ContextSwitch

        public ContextSwitch(TraceEvent sw)
        {
            // Old thread id & process id
            this.OldThreadId = (int)sw.PayloadValue(0);
            this.OldProcessId = (int)sw.PayloadValue(1);
            this.NewThreadId = (int)sw.PayloadValue(3);
            this.NewProcessId = (int)sw.PayloadValue(4);
            this.State = (ThreadState)sw.PayloadValue(13);
            this.ProcessorNumber = sw.ProcessorNumber;
            this.TimeStamp = sw.TimeStamp;
            this.TimeStamp100ns = sw.TimeStamp100ns;

            // Multiply by 10 to adjust the time as 100ns
            this.NewThreadWaitTime = (int)sw.PayloadValue(15) * 10;
        }
开发者ID:TCDBerenger,项目名称:harvester,代码行数:15,代码来源:ContextSwitch.cs


示例20: ThreadStorageView

 /// <summary>
 /// ThreadStorageView constructor.
 /// </summary>
 /// <param name="applicationId"></param>
 /// <param name="threadId"></param>
 /// <param name="state"></param>
 public ThreadStorageView(
     string applicationId,
     int threadId,
     ThreadState state
     )
     : this(-1,
     applicationId,
     null,
     threadId,
     state,
     c_noTimeSet,
     c_noTimeSet,
     0,
     false)
 {
 }
开发者ID:JamesTryand,项目名称:alchemi,代码行数:22,代码来源:ThreadStorageView.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ThreatLevel类代码示例发布时间:2022-05-24
下一篇:
C# ThreadStart类代码示例发布时间: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