示例#1
0
 public void Dispose()
 {
     if (handler != null)
     {
         EventBetter.UnlistenHandler(typeof(MessageType), handler);
         handler = null;
     }
 }
示例#2
0
    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);
        }
    }