a guest Jul 22nd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- BlockingCollection<myEventArgs> myTasks = new BlockingCollection<myEventArgs>();
- private void myEventHandler(object sender, myEventArgs e)
- private void doWork()
- while (myTasks.IsCompleted == false)
- //Do some work here with the third party API.
- var eArgs = myTasks.Take();
- //Sometimes I have a background (thread safe) task to perform.
- //This is submitted to the thread pool.
- Task.Run(() => doSomeBackgroundWork());
RAW Paste Data