Beispiel #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            ib?.Dispose();
            ib         = new IdleBus(TimeSpan.FromSeconds(10));
            ib.Notice += (_, e2) =>
            {
                var log = $"[{DateTime.Now.ToString("HH:mm:ss")}] 线程{Thread.CurrentThread.ManagedThreadId}:{e2.Log}";
                //Trace.WriteLine(log);
                Console.WriteLine(log);
            };

            ib
            .Register("key1", () => new ManualResetEvent(false))
            .Register("key2", () => new AutoResetEvent(false));

            for (var a = 3; a < 2000; a++)
            {
                ib.Register("key" + a, () => new System.Data.SqlClient.SqlConnection());
            }
        }
Beispiel #2
0
 public void Dispose()
 {
     if (isdisposed)
     {
         return;
     }
     lock (isdisposedLock)
     {
         if (isdisposed)
         {
             return;
         }
         isdisposed = true;
     }
     _ib?.Dispose();
     _wq?.Dispose();
     _tasks?.Clear();
     Interlocked.Exchange(ref _quantityTempTask, 0);
     Interlocked.Exchange(ref _quantityTask, 0);
     (_taskHandler as IDisposable)?.Dispose();
 }
Beispiel #3
0
 public override void Dispose()
 {
     _ib.Dispose();
 }