public void Dispose() { if (handler != null) { EventBetter.UnlistenHandler(typeof(MessageType), handler); handler = null; } }
public static async Task <MessageType> ListenAsync <MessageType>() { var tcs = new TaskCompletionSource <MessageType>(); var handler = RegisterInternal <object, MessageType>(s_entries, (msg) => tcs.SetResult(msg), HandlerFlags.DontInvokeIfAddedInAHandler); try { return(await tcs.Task); } finally { EventBetter.UnlistenHandler(typeof(MessageType), handler); } }