Example #1
0
 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;
 }
Example #2
0
 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);
 }
Example #3
0
 protected override void InternalRelease(RichThread thread)
 {
     if (waitHandle != null)
     {
         waitHandle.ReleaseMutex();
     }
 }
 internal void AddThread(RichThread thread)
 {
     lock (items)
     {
         items.Add(thread);
     }
 }
Example #5
0
 public SyncObject(string name, bool isRemote, IntPtr formHandle, RichThread thread)
 {
     this.name = name;
     this.isRemote = isRemote;
     this.formHandle = formHandle;
     this.thread = thread;
 }
Example #6
0
 protected override void InternalRelease(RichThread thread)
 {
     if (freeCount < maxCount)
     {
         freeCount = waitHandle.Release() + 1;
     }
 }
Example #7
0
 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;
 }
Example #8
0
 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;
            }
        }
Example #10
0
        /// <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);
            }
        }
Example #11
0
 /// <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;
 }
Example #12
0
 /// <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);
         }
     }
 }
Example #13
0
 /// <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)
 {
 }
Example #15
0
        private void RemoveWaitingThread(RichThread thread)
        {
            lock (waitingThreads)
            {
                waitingThreads.Remove(thread);
                if (isRemote && formHandle != IntPtr.Zero)
                {

                }
                if (WaitingThreadRemoved != null)
                {
                    WaitingThreadRemoved(this, thread);
                }
                DoChanged();
            }
        }
Example #16
0
        private void RemoveProcessThread(RichThread thread)
        {
            lock (processThreads)
            {
                processThreads.Remove(thread);
                if (isRemote && formHandle != IntPtr.Zero)
                {

                }
                if (ProcessThreadRemoved != null)
                {
                    ProcessThreadRemoved(this, thread);
                }
                DoChanged();
            }
        }
Example #17
0
 protected abstract void InternalRelease(RichThread thread);
Example #18
0
 public void Release(RichThread thread)
 {
     lock (thisLock)
     {
         RemoveProcessThread(thread);
         InternalRelease(thread);
     }
 }
Example #19
0
 public virtual void EndWait(RichThread waitThread)
 {
     lock (thisLock)
     {
         RemoveWaitingThread(waitThread);
         AddProcessThread(waitThread);
     }
 }
Example #20
0
 public void BeginWait(RichThread waitThread)
 {
     AddWaitingThread(waitThread);
 }
Example #21
0
 public BackgroundThread(string name, RichThread parent, ThreadStart start)
     : this(name, parent)
 {
     this.start = start;
 }
Example #22
0
 protected override void InternalRelease(RichThread thread)
 {
     //�������
 }