Exemple #1
0
        public void MTAWorkerThread2()
        {
Label0:
            this.doIndicate.WaitOne();
            if (this.alive)
            {
                while (true)
                {
                    EventSource.MTARequest item = null;
                    lock (this.critSec)
                    {
                        if (this.reqList.Count <= 0)
                        {
                            goto Label0;
                        }
                        else
                        {
                            item = (EventSource.MTARequest) this.reqList[0];
                            this.reqList.RemoveAt(0);
                        }
                    }
                    try
                    {
                        try
                        {
                            if (this.pSinkMTA != null)
                            {
                                int num = this.pSinkMTA.Indicate_(item.lengthFromSTA, item.objectsFromSTA);
                                if (num < 0)
                                {
                                    if (((long)num & (long)-4096) != (long)-2147217408)
                                    {
                                        Marshal.ThrowExceptionForHR(num);
                                    }
                                    else
                                    {
                                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)num);
                                    }
                                }
                            }
                        }
                        catch (Exception exception1)
                        {
                            Exception exception = exception1;
                            item.exception = exception;
                        }
                    }
                    finally
                    {
                        item.doneIndicate.Set();
                        GC.KeepAlive(this);
                    }
                }
            }
            else
            {
                return;
            }
        }
Exemple #2
0
 public void IndicateEvents(int length, IntPtr[] objects)
 {
     if (this.pSinkMTA != null)
     {
         if (!MTAHelper.IsNoContextMTA())
         {
             EventSource.MTARequest mTARequest = new EventSource.MTARequest(length, objects);
             lock (this.critSec)
             {
                 if (!this.workerThreadInitialized)
                 {
                     Thread thread = new Thread(new ThreadStart(this.MTAWorkerThread2));
                     thread.IsBackground = true;
                     thread.SetApartmentState(ApartmentState.MTA);
                     thread.Start();
                     this.workerThreadInitialized = true;
                 }
                 int num = this.reqList.Add(mTARequest);
                 if (!this.doIndicate.Set())
                 {
                     this.reqList.RemoveAt(num);
                     throw new ManagementException(RC.GetString("WORKER_THREAD_WAKEUP_FAILED"));
                 }
             }
             mTARequest.doneIndicate.WaitOne();
             if (mTARequest.exception != null)
             {
                 throw mTARequest.exception;
             }
         }
         else
         {
             int num1 = this.pSinkMTA.Indicate_(length, objects);
             if (num1 < 0)
             {
                 if (((long)num1 & (long)-4096) != (long)-2147217408)
                 {
                     Marshal.ThrowExceptionForHR(num1);
                 }
                 else
                 {
                     ManagementException.ThrowWithExtendedInfo((ManagementStatus)num1);
                 }
             }
         }
         GC.KeepAlive(this);
         return;
     }
     else
     {
         return;
     }
 }
Exemple #3
0
		public void IndicateEvents(int length, IntPtr[] objects)
		{
			if (this.pSinkMTA != null)
			{
				if (!MTAHelper.IsNoContextMTA())
				{
					EventSource.MTARequest mTARequest = new EventSource.MTARequest(length, objects);
					lock (this.critSec)
					{
						if (!this.workerThreadInitialized)
						{
							Thread thread = new Thread(new ThreadStart(this.MTAWorkerThread2));
							thread.IsBackground = true;
							thread.SetApartmentState(ApartmentState.MTA);
							thread.Start();
							this.workerThreadInitialized = true;
						}
						int num = this.reqList.Add(mTARequest);
						if (!this.doIndicate.Set())
						{
							this.reqList.RemoveAt(num);
							throw new ManagementException(RC.GetString("WORKER_THREAD_WAKEUP_FAILED"));
						}
					}
					mTARequest.doneIndicate.WaitOne();
					if (mTARequest.exception != null)
					{
						throw mTARequest.exception;
					}
				}
				else
				{
					int num1 = this.pSinkMTA.Indicate_(length, objects);
					if (num1 < 0)
					{
						if (((long)num1 & (long)-4096) != (long)-2147217408)
						{
							Marshal.ThrowExceptionForHR(num1);
						}
						else
						{
							ManagementException.ThrowWithExtendedInfo((ManagementStatus)num1);
						}
					}
				}
				GC.KeepAlive(this);
				return;
			}
			else
			{
				return;
			}
		}