public MutexObject(string name, bool initiallyOwned, IntPtr formHandle, RichThread thread) : base(name, false, formHandle, thread) { bool result = false; this.waitHandle = new Mutex(initiallyOwned, name, out result); if (!result) this.waitHandle = null; }
public SemaphoreObject(string name, int maxCount, int freeCount, IntPtr formHandle, RichThread thread) : base(name, false, formHandle, thread) { this.maxCount = maxCount; this.freeCount = freeCount; this.waitHandle = new Semaphore(freeCount, maxCount); }
protected override void InternalRelease(RichThread thread) { if (waitHandle != null) { waitHandle.ReleaseMutex(); } }
internal void AddThread(RichThread thread) { lock (items) { items.Add(thread); } }
public SyncObject(string name, bool isRemote, IntPtr formHandle, RichThread thread) { this.name = name; this.isRemote = isRemote; this.formHandle = formHandle; this.thread = thread; }
protected override void InternalRelease(RichThread thread) { if (freeCount < maxCount) { freeCount = waitHandle.Release() + 1; } }
public BackgroundThread(string name, RichThread parent) : base(name, parent, (System.Threading.Thread)null) { this.innerThread = new System.Threading.Thread(new ThreadStart(this.SysExecute)); this.innerThread.Name = name; this.InnerThread.IsBackground = true; }
public override void EndWait(RichThread thread) { lock (thisLock) { freeCount--; base.EndWait(thread); } }
public GarbageCollectionThread(string name, RichThread parent, int intervalSeconds) : base(name, parent) { this.innerThread.Priority = System.Threading.ThreadPriority.AboveNormal; if (intervalSeconds > 0) { this.inintervalMilliseconds = intervalSeconds * 1000; } }
/// <summary> /// ���캯�� /// </summary> /// <param name="name">����</param> /// <param name="isAutoTurnOff">��ij���̵߳ȴ�����ʱ���Ƿ��Զ�����Ϊ"Off"</param> /// <param name="isOn">�Ƿ�ΪOn״̬��Wait��������������</param> /// <param name="formHandle">���ھ��</param> /// <param name="thread">�����õƵ��߳�</param> public LightObject(string name, bool isAutoTurnOff, bool isOn, IntPtr formHandle, RichThread thread) : base(name, false, formHandle, thread) { this._isAutoTurnOff = isAutoTurnOff; if (isAutoTurnOff) { waitHandle = new AutoResetEvent(isOn); } else { waitHandle = new ManualResetEvent(isOn); } }
/// <summary> /// 构造函数。 /// </summary> /// <param name="name"></param> /// <param name="parent"></param> public ServiceThread(string name, RichThread parent) : base(name, parent) { this.innerThread.Priority = System.Threading.ThreadPriority.AboveNormal; }
/// <summary> /// �����̶߳��� /// </summary> /// <param name="thread"></param> public static void AddThread(RichThread thread) { if (!thread.IsValid) { throw new FireSpiderException("���Ϸ����̶߳���"); } lock (threadList) { RichThread tempThread = GetThread(thread.Name); if (tempThread != null) { if (tempThread == thread) { throw new FireSpiderException("�������һ���̶߳����μ��뵽�߳̿�������"); } throw new FireSpiderException("�Ѿ�����һ������Ϊ\"" + thread.Name + "\"���̶߳���"); } threadList.Add(thread.Name, thread); if (thread is MainThread) { mainThread = thread; } if (ThreadAdded != null) { ThreadAdded(thread); } } }
/// <summary> /// �߳��Ƿ���ڡ� /// </summary> /// <param name="thread">�̶߳���</param> /// <returns></returns> public static bool ExistsThread(RichThread thread) { lock (threadList) { foreach (RichThread tempThread in threadList) { if (tempThread == thread) return true; } return false; } }
/// <summary> /// 构造函数。 /// </summary> /// <param name="name"></param> /// <param name="parent"></param> public HandlerServiceThread(string name, RichThread parent) : base(name, parent) { }
private void RemoveWaitingThread(RichThread thread) { lock (waitingThreads) { waitingThreads.Remove(thread); if (isRemote && formHandle != IntPtr.Zero) { } if (WaitingThreadRemoved != null) { WaitingThreadRemoved(this, thread); } DoChanged(); } }
private void RemoveProcessThread(RichThread thread) { lock (processThreads) { processThreads.Remove(thread); if (isRemote && formHandle != IntPtr.Zero) { } if (ProcessThreadRemoved != null) { ProcessThreadRemoved(this, thread); } DoChanged(); } }
protected abstract void InternalRelease(RichThread thread);
public void Release(RichThread thread) { lock (thisLock) { RemoveProcessThread(thread); InternalRelease(thread); } }
public virtual void EndWait(RichThread waitThread) { lock (thisLock) { RemoveWaitingThread(waitThread); AddProcessThread(waitThread); } }
public void BeginWait(RichThread waitThread) { AddWaitingThread(waitThread); }
public BackgroundThread(string name, RichThread parent, ThreadStart start) : this(name, parent) { this.start = start; }
protected override void InternalRelease(RichThread thread) { //������� }