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


C# Threading.STPStartInfo类代码示例

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


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

示例1: STPAndWIGStartSuspended

        public void STPAndWIGStartSuspended()
        {
            STPStartInfo stpStartInfo = new STPStartInfo();
            stpStartInfo.StartSuspended = true;

            SmartThreadPool stp = new SmartThreadPool(stpStartInfo);

            WIGStartInfo wigStartInfo = new WIGStartInfo();
            wigStartInfo.StartSuspended = true;

            IWorkItemsGroup wig = stp.CreateWorkItemsGroup(10, wigStartInfo);

            wig.QueueWorkItem(new WorkItemCallback(this.DoWork));

            Assert.IsFalse(wig.WaitForIdle(200));

            wig.Start();

            Assert.IsFalse(wig.WaitForIdle(200));

            stp.Start();

            Assert.IsTrue(wig.WaitForIdle(5000), "WIG is not idle");
            Assert.IsTrue(stp.WaitForIdle(5000), "STP is not idle");
        }
开发者ID:jogibear9988,项目名称:smartthreadpool,代码行数:25,代码来源:TestStartSuspended.cs

示例2: DisposeCallerState

        public void DisposeCallerState() 
        { 
            STPStartInfo stpStartInfo = new STPStartInfo();
            stpStartInfo.DisposeOfStateObjects = true;
     
            SmartThreadPool smartThreadPool = new SmartThreadPool(stpStartInfo);

            CallerState nonDisposableCallerState = new NonDisposableCallerState();
            CallerState disposableCallerState = new DisposableCallerState();

            IWorkItemResult wir1 = 
                smartThreadPool.QueueWorkItem(
                new WorkItemCallback(this.DoSomeWork), 
                nonDisposableCallerState);

            IWorkItemResult wir2 = 
                smartThreadPool.QueueWorkItem(
                new WorkItemCallback(this.DoSomeWork), 
                disposableCallerState);

            wir1.GetResult();
			Assert.AreEqual(1, nonDisposableCallerState.Value);

            wir2.GetResult();

			// Wait a little bit for the working thread to call dispose on the 
			// work item's state.
			smartThreadPool.WaitForIdle();

			Assert.AreEqual(2, disposableCallerState.Value);

            smartThreadPool.Shutdown();
        } 
开发者ID:laoqiuChina,项目名称:SmartThreadPool,代码行数:33,代码来源:TestStateDispose.cs

示例3: CancelCanceledWorkItem

        public void CancelCanceledWorkItem()
        {
            STPStartInfo stpStartInfo = new STPStartInfo();
            stpStartInfo.StartSuspended = true;

            SmartThreadPool stp = new SmartThreadPool(stpStartInfo);
            IWorkItemResult wir = stp.QueueWorkItem(state => null);

            int counter = 0;

            wir.Cancel();

            try
            {
                wir.GetResult();
            }
            catch (WorkItemCancelException ce)
            {
                ce.GetHashCode();
                ++counter;
            }

            Assert.AreEqual(counter, 1);

            wir.Cancel();

            try
            {
                wir.GetResult();
            }
            finally
            {
                stp.Shutdown();
            }
        }
开发者ID:jogibear9988,项目名称:smartthreadpool,代码行数:35,代码来源:TestCancel.cs

示例4: STPStartInfo

 public STPStartInfo(STPStartInfo stpStartInfo)
     : base(stpStartInfo)
 {
     _idleTimeout = stpStartInfo.IdleTimeout;
     _minWorkerThreads = stpStartInfo.MinWorkerThreads;
     _maxWorkerThreads = stpStartInfo.MaxWorkerThreads;
     _threadPriority = stpStartInfo.ThreadPriority;
     _performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName;
 }
开发者ID:vls,项目名称:hp2p,代码行数:9,代码来源:STPStartInfo.cs

示例5: STPStartInfo

 public STPStartInfo(STPStartInfo stpStartInfo) : base(stpStartInfo)
 {
     _idleTimeout = stpStartInfo._idleTimeout;
     _minWorkerThreads = stpStartInfo._minWorkerThreads;
     _maxWorkerThreads = stpStartInfo._maxWorkerThreads;
     _threadPriority = stpStartInfo._threadPriority;
     _pcInstanceName = stpStartInfo._pcInstanceName;
     _stackSize = stpStartInfo._stackSize;
 }
开发者ID:nathanmarck,项目名称:Aurora-Sim,代码行数:9,代码来源:STPStartInfo.cs

示例6: CheckSinglePriority

        private void CheckSinglePriority(ThreadPriority threadPriority)
        {
            STPStartInfo stpStartInfo = new STPStartInfo();
            stpStartInfo.ThreadPriority = threadPriority;

            SmartThreadPool stp = new SmartThreadPool(stpStartInfo);

            IWorkItemResult wir = stp.QueueWorkItem(new WorkItemCallback(GetThreadPriority));
            ThreadPriority currentThreadPriority = (ThreadPriority)wir.GetResult();

            Assert.AreEqual(threadPriority, currentThreadPriority);
        }
开发者ID:jogibear9988,项目名称:smartthreadpool,代码行数:12,代码来源:TestThreadPriority.cs

示例7: STPStartInfo

 public STPStartInfo(STPStartInfo stpStartInfo)
     : base(stpStartInfo)
 {
     _idleTimeout = stpStartInfo.IdleTimeout;
     _minWorkerThreads = stpStartInfo.MinWorkerThreads;
     _maxWorkerThreads = stpStartInfo.MaxWorkerThreads;
     _threadPriority = stpStartInfo.ThreadPriority;
     _performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName;
     _enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters;
     _threadPoolName = stpStartInfo._threadPoolName;
     _areThreadsBackground = stpStartInfo.AreThreadsBackground;
     ThreadApartmentState = stpStartInfo.ThreadApartmentState;
 }
开发者ID:MattHoneycutt,项目名称:stp,代码行数:13,代码来源:STPStartInfo.cs

示例8: QueueWorkItem_WhenMaxIsNull_Queues

        public void QueueWorkItem_WhenMaxIsNull_Queues()
        {
            var info = new STPStartInfo
            {
                MaxQueueLength = null,
            };
            var pool = new SmartThreadPool(info);
            pool.Start();
            var workItem = pool.QueueWorkItem<object>(ReturnNull);

            // If rejected, an exception would have been thrown instead.
            Assert.IsTrue(workItem.GetResult() == null);
        }
开发者ID:amibar,项目名称:SmartThreadPool,代码行数:13,代码来源:TestMaxQueueLength.cs

示例9: STPStartInfo

 // Token: 0x06001842 RID: 6210
 // RVA: 0x00074F58 File Offset: 0x00073158
 public STPStartInfo(STPStartInfo stpstartInfo_0)
     : base(stpstartInfo_0)
 {
     this._idleTimeout = stpstartInfo_0.IdleTimeout;
     this._minWorkerThreads = stpstartInfo_0.MinWorkerThreads;
     this._maxWorkerThreads = stpstartInfo_0.MaxWorkerThreads;
     this._threadPriority = stpstartInfo_0.ThreadPriority;
     this._performanceCounterInstanceName = stpstartInfo_0.PerformanceCounterInstanceName;
     this._enableLocalPerformanceCounters = stpstartInfo_0._enableLocalPerformanceCounters;
     this._threadPoolName = stpstartInfo_0._threadPoolName;
     this._areThreadsBackground = stpstartInfo_0.AreThreadsBackground;
     this._apartmentState = stpstartInfo_0._apartmentState;
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:15,代码来源:STPStartInfo.cs

示例10: Init

        public static bool Init(bool useSmartThredPool)
        {
            if (Pool == null)
            {
                STPStartInfo param = new STPStartInfo();
                param.MinWorkerThreads = 2;
                param.MaxWorkerThreads = 50;
                param.ThreadPoolName = "LibOpenMetaverse Main ThreadPool";
                param.AreThreadsBackground = true;

                Pool = new SmartThreadPool(param);
            }
            return true;
        }
开发者ID:jakzodiac,项目名称:libopenmetaverse,代码行数:14,代码来源:WorkPool.cs

示例11: InitSTP

        private void InitSTP()
        {
            STPStartInfo stpStartInfo =
                new STPStartInfo
                {
                    StartSuspended = true,
                    MaxWorkerThreads = ((int)spinCon6.Value),
                    IdleTimeout = int.Parse(spinIdleTimeout.Text) * 1000,
                };

            if (_useWindowsPerformanceCounters)
            {
                stpStartInfo.PerformanceCounterInstanceName = "WIG Test SmartThreadPool";
            }
            else
            {
                stpStartInfo.EnableLocalPerformanceCounters = true;
            }

            _smartThreadPool = new SmartThreadPool(stpStartInfo);
            WIGStartInfo wigStartInfo = new WIGStartInfo()
            {
                FillStateWithArgs = true,
            };
            _wig1 = _smartThreadPool.CreateWorkItemsGroup((int)spinCon1.Value, wigStartInfo);
            _wig2 = _smartThreadPool.CreateWorkItemsGroup((int)spinCon2.Value, wigStartInfo);
            _wig3 = _smartThreadPool.CreateWorkItemsGroup((int)spinCon3.Value, wigStartInfo);

            spinCon1.Tag = _wig1;
            spinCon2.Tag = _wig2;
            spinCon3.Tag = _wig3;
            spinCon6.Tag = _smartThreadPool;

            comboWIPriority1.SelectedIndex = 1;
            comboWIPriority2.SelectedIndex = 1;
            comboWIPriority3.SelectedIndex = 1;
            comboWIPriority6.SelectedIndex = 1;

            _wigEntries = new WigEntry[]
            {
                new WigEntry(_wig1, queueUsageControl1, lblStatus1),
                new WigEntry(_wig2, queueUsageControl2, lblStatus2),
                new WigEntry(_wig3, queueUsageControl3, lblStatus3),
            };
            for (int i = 0; i < _lastIndex.Length; i++)
            {
                _lastIndex[i] = 1;
            }
        }
开发者ID:laoqiuChina,项目名称:SmartThreadPool,代码行数:49,代码来源:Form1.cs

示例12: Worker

        static Worker()
        {
            STPStartInfo stpStartInfo = new STPStartInfo();

            stpStartInfo.IdleTimeout = Worker.IdleTimeoutConfig * 1000;
            stpStartInfo.PerformanceCounterInstanceName = Worker.instanceName;
            stpStartInfo.MaxWorkerThreads = 300;

            Worker.smartThreadPool = new SmartThreadPool(stpStartInfo);

            _getActiveThreads = () => (long)smartThreadPool.ActiveThreads;
            _getInUseThreads = () => (long)smartThreadPool.InUseThreads;
            _getQueuedWorkItems = () => (long)smartThreadPool.CurrentWorkItemsCount;
            _getCompletedWorkItems = () => (long)smartThreadPool.WorkItemsProcessed;
        }
开发者ID:nambok,项目名称:twitterRT,代码行数:15,代码来源:Worker.cs

示例13: CheckIsBackground

        private static void CheckIsBackground(bool isBackground)
	    {
	        STPStartInfo stpStartInfo = new STPStartInfo();
	        stpStartInfo.AreThreadsBackground = isBackground;

	        SmartThreadPool stp = new SmartThreadPool(stpStartInfo);

            IWorkItemResult<bool> wir = stp.QueueWorkItem(() => GetCurrentThreadIsBackground());

	        bool resultIsBackground = wir.GetResult();

	        stp.WaitForIdle();

            Assert.AreEqual(isBackground, resultIsBackground);
	    }
开发者ID:laoqiuChina,项目名称:SmartThreadPool,代码行数:15,代码来源:TestThreadIsBackground.cs

示例14: StartSuspended

        public void StartSuspended()
        {
            STPStartInfo stpStartInfo = new STPStartInfo();
            stpStartInfo.StartSuspended = true;

            SmartThreadPool stp = new SmartThreadPool(stpStartInfo);

            stp.QueueWorkItem(new WorkItemCallback(this.DoWork));

            Assert.IsFalse(stp.WaitForIdle(200));

            stp.Start();

            Assert.IsTrue(stp.WaitForIdle(200));
        }
开发者ID:jogibear9988,项目名称:smartthreadpool,代码行数:15,代码来源:TestStartSuspended.cs

示例15: CheckApartmentState

	    private static void CheckApartmentState(ApartmentState requestApartmentState)
	    {
	        STPStartInfo stpStartInfo = new STPStartInfo();
            stpStartInfo.ApartmentState = requestApartmentState;

	        SmartThreadPool stp = new SmartThreadPool(stpStartInfo);

	        IWorkItemResult<ApartmentState> wir = stp.QueueWorkItem(() => GetCurrentThreadApartmentState());

	        ApartmentState resultApartmentState = wir.GetResult();

	        stp.WaitForIdle();

	        Assert.AreEqual(requestApartmentState, resultApartmentState);
	    }
开发者ID:laoqiuChina,项目名称:SmartThreadPool,代码行数:15,代码来源:TestThreadApartmentState.cs


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