What is the class that places the action on the dispatcher queue, if it is not already

I wrote a simple class that works with UIElement and an action to call. Whenever an action is invoked, it places the action on the dispatcher queue if it does not already exist. I use it to reduce the number of calls.

class NoNameClass
{
 // has element and action in its ctor.

 void NoNameMethod()
 {
  if (!inQueue)
  {
   inQueue = true;
   element.Dispatcher.BeginInvoke(()=> 
    {
      inQueue = false;
      action();
    }
  }
 }
 bool inQueue;
}

Can you suggest a name for this class and method? Thanks

+3
source share
2 answers

As a name for the class, I will define "DispatcherAction" and a method that I would call "Queue".

, "" "" , , . , .

Update: , , , "TryQueue" . "true", , "false", , .

+1

DispatchManager Start()?

0

Source: https://habr.com/ru/post/1756865/


All Articles