public async Task <T> ScheduleActionAsync <T>(ChatAction act, TimeSpan timeout) { act.ThrowIfNull(nameof(act)); var wait = new AutoResetEvent(false); object data = null; act.CallBack = new Action <object>(x => { data = x; wait.Set(); }); actionQueue.Enqueue(act); queueMre.Set(); await Task.Run(() => wait.WaitOne(timeout)); return((T)data); }
public Task <T> ScheduleActionAsync <T>(ChatAction act) { return(ScheduleActionAsync <T>(act, Timeout.InfiniteTimeSpan)); }