1234567891011121314151617181920212223242526272829303132333435 |
- namespace FNZCM.BlazorWasm.Helpers
- {
- public static class TimeoutHelper
- {
- public static void SetTimeout(int ms, params Func<Task>[] actions)
- {
- int index = 0;
- var t = new System.Timers.Timer(ms);
- t.Elapsed += async delegate
- {
- t.Stop();
- try
- {
- await actions[index]?.Invoke();
- }
- finally
- {
- ++index;
- if (index >= actions.Length)
- {
- t.Stop();
- t.Dispose();
- t = null;
- }
- else
- {
- t.Start();
- }
- }
- };
- t.Start();
- }
- }
- }
|