I want to do something like this in C# (more specifically, WPF):
Thread.Invoke(MyCallback, 1000);
Which will just call MyCallback, 1 time, 1 second from now.
What is the easiest way to do this with .NET? Do I have to setup a Timer and hook an event?
You can use System.Timers.Timer to do this without spawning your own thread. Implement the Elapsed callback to do what you want, setting
Enabledtrue andAutoResetfalse to achieve a single invocation.Make sure you
DisposetheTimerobject once you are done with it!