I have that code where my action is never executed:
private static Timer timer = new Timer(TimerCallback, null, 5000, 5000);
private static DispatcherOperation dispatcherOperationPrevious = null;
private static void TimerCallback(object state)
{
DispatcherOperation dispatcherOperation =
Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
{
Debug.Print("Pass here at: " + DateTime.Now.ToString("O"));
}));
dispatcherOperationPrevious = dispatcherOperation;
}
I have no debug traces about "Pass here...".
If I look at the result of BeginInvoke which is dispatcherOperation, I get (either for current or previous dispatcherOperation):
dispatcherOperation.Status = Pending
dispatcherOperation.Task.Status = WaitingForActivation
_dispatcherOperationPrevious .Status = Pending
_dispatcherOperationPrevious .Task.Status = WaitingForActivation
Why "Debug.Print..." is never executed?