DisableComObjectEagerCleanup() public method

public DisableComObjectEagerCleanup ( ) : void
return void
Beispiel #1
0
 private static void Thread_Demo3()
 {
     System.Threading.Thread t1 = new System.Threading.Thread(delegate()
     {
         for (int i = 0; i < 1000; i++)
         {
             Console.WriteLine("Hello" + i);
         }
     });
     t1.DisableComObjectEagerCleanup();
 }
 /// <summary>
 /// This is deprecated, this needs to be converted to using the new HttpRrquest method as WinForms really shouldnt be used in a web session.
 /// </summary>
 public DepartmentListControl()
 {
     deptNodes = new List<HtmlNode>();
     thrd = new Thread(new ThreadStart(
         delegate
         {
             Init();
             System.Windows.Forms.Application.Run(this);
         }));
     thrd.DisableComObjectEagerCleanup();
     // set thread to STA state before starting
     thrd.SetApartmentState(ApartmentState.STA);
     thrd.Start();
     thrd.Join();
 }
 public SemesterControl(string log)
 {
     logFile = log;
     thrd = new Thread(new ThreadStart(
         delegate
         {
             Init();
             System.Windows.Forms.Application.Run(this);
         }));
     thrd.DisableComObjectEagerCleanup();
     // set thread to STA state before starting
     thrd.SetApartmentState(ApartmentState.STA);
     thrd.Start();
     thrd.Join();
     Log("Destroying Thread");
 }
Beispiel #4
0
 public override void Run()
 {
     for(int i=0; i < N; i++)
     {
         Thread t = new Thread(() => DoSomething(i));
         t.Name = $"Thread #{i}";
         t.Start();
         switch(i%8)
         {
             case 0:
                 t.Abort();
                 break;
             case 1:
                 t.DisableComObjectEagerCleanup();
                 break;
             case 2:
                 t.IsBackground = true;
                 break;
             case 3:
                 t.Interrupt();
                 break;
             case 4:
                 t.Priority = ThreadPriority.AboveNormal;
                 break;
             case 5:
                 t.Priority = ThreadPriority.BelowNormal;
                 break;
             case 6:
                 t.Priority = ThreadPriority.Highest;
                 break;
             case 7:
                 t.Priority = ThreadPriority.Lowest;
                 break;
         }
     }
 }
        private void Init()
        {
            try
            {
                thrd = new Thread(new ThreadStart(delegate
                {
                    AttachHandlers();
                    ProcessNextSearch();

                    System.Windows.Forms.Application.Run(this);

                }));
                thrd.DisableComObjectEagerCleanup();
                thrd.SetApartmentState(ApartmentState.STA);
                thrd.Start();
                thrd.Join();
            }
            catch (Exception ex)
            {
                Log(ex.Message);
                if (ex.InnerException != null && ex.InnerException.Message != null)
                    Log(ex.InnerException.Message);

                Application.Exit();
            }
        }