本文整理汇总了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");
}
示例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();
}
示例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();
}
}
示例4: STPStartInfo
public STPStartInfo(STPStartInfo stpStartInfo)
: base(stpStartInfo)
{
_idleTimeout = stpStartInfo.IdleTimeout;
_minWorkerThreads = stpStartInfo.MinWorkerThreads;
_maxWorkerThreads = stpStartInfo.MaxWorkerThreads;
_threadPriority = stpStartInfo.ThreadPriority;
_performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}