コード例 #1
0
ファイル: MutexObject.cs プロジェクト: jihadbird/firespider
 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;
 }
コード例 #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);
 }
コード例 #3
0
ファイル: MutexObject.cs プロジェクト: jihadbird/firespider
 protected override void InternalRelease(RichThread thread)
 {
     if (waitHandle != null)
     {
         waitHandle.ReleaseMutex();
     }
 }
コード例 #4
0
 internal void AddThread(RichThread thread)
 {
     lock (items)
     {
         items.Add(thread);
     }
 }
コード例 #5
0
ファイル: SyncObject.cs プロジェクト: jihadbird/firespider
 public SyncObject(string name, bool isRemote, IntPtr formHandle, RichThread thread)
 {
     this.name = name;
     this.isRemote = isRemote;
     this.formHandle = formHandle;
     this.thread = thread;
 }
コード例 #6
0
 protected override void InternalRelease(RichThread thread)
 {
     if (freeCount < maxCount)
     {
         freeCount = waitHandle.Release() + 1;
     }
 }
コード例 #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;
 }
コード例 #8
0
 public override void EndWait(RichThread thread)
 {
     lock (thisLock)
     {
         freeCount--;
         base.EndWait(thread);
     }
 }
コード例 #9
0
        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;
            }
        }
コード例 #10
0
ファイル: LightObject.cs プロジェクト: jihadbird/firespider
        /// <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);
            }
        }
コード例 #11
0
ファイル: ServiceThread.cs プロジェクト: jihadbird/firespider
 /// <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;
 }
コード例 #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);
         }
     }
 }
コード例 #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;
     }
 }
コード例 #14
0
 /// <summary>
 /// 构造函数。
 /// </summary>
 /// <param name="name"></param>
 /// <param name="parent"></param>
 public HandlerServiceThread(string name, RichThread parent)
     : base(name, parent)
 {
 }
コード例 #15
0
ファイル: SyncObject.cs プロジェクト: jihadbird/firespider
        private void RemoveWaitingThread(RichThread thread)
        {
            lock (waitingThreads)
            {
                waitingThreads.Remove(thread);
                if (isRemote && formHandle != IntPtr.Zero)
                {

                }
                if (WaitingThreadRemoved != null)
                {
                    WaitingThreadRemoved(this, thread);
                }
                DoChanged();
            }
        }
コード例 #16
0
ファイル: SyncObject.cs プロジェクト: jihadbird/firespider
        private void RemoveProcessThread(RichThread thread)
        {
            lock (processThreads)
            {
                processThreads.Remove(thread);
                if (isRemote && formHandle != IntPtr.Zero)
                {

                }
                if (ProcessThreadRemoved != null)
                {
                    ProcessThreadRemoved(this, thread);
                }
                DoChanged();
            }
        }
コード例 #17
0
ファイル: SyncObject.cs プロジェクト: jihadbird/firespider
 protected abstract void InternalRelease(RichThread thread);
コード例 #18
0
ファイル: SyncObject.cs プロジェクト: jihadbird/firespider
 public void Release(RichThread thread)
 {
     lock (thisLock)
     {
         RemoveProcessThread(thread);
         InternalRelease(thread);
     }
 }
コード例 #19
0
ファイル: SyncObject.cs プロジェクト: jihadbird/firespider
 public virtual void EndWait(RichThread waitThread)
 {
     lock (thisLock)
     {
         RemoveWaitingThread(waitThread);
         AddProcessThread(waitThread);
     }
 }
コード例 #20
0
ファイル: SyncObject.cs プロジェクト: jihadbird/firespider
 public void BeginWait(RichThread waitThread)
 {
     AddWaitingThread(waitThread);
 }
コード例 #21
0
 public BackgroundThread(string name, RichThread parent, ThreadStart start)
     : this(name, parent)
 {
     this.start = start;
 }
コード例 #22
0
ファイル: LightObject.cs プロジェクト: jihadbird/firespider
 protected override void InternalRelease(RichThread thread)
 {
     //�������
 }