Created
May 26, 2011 21:20
-
-
Save kthompson/994113 to your computer and use it in GitHub Desktop.
Utilities Module Messaging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
namespace UtilitiesBase | |
{ | |
public class MessageEventArgs : EventArgs | |
{ | |
public MessageEventArgs(object request, Action<object> callback) | |
{ | |
this.Request = request; | |
this.Callback = callback; | |
} | |
public object Request { get; private set; } | |
public Action<object> Callback { get; private set; } | |
} | |
public class Messaging | |
{ | |
public static void SendRequest(object sender, object request, Action<object> callback) | |
{ | |
OnRequest(sender, new MessageEventArgs(request, callback)); | |
} | |
public static event EventHandler<MessageEventArgs> Request; | |
private static void OnRequest(object sender, MessageEventArgs args) | |
{ | |
var handler = Request; | |
if (handler != null) | |
handler(sender, args); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment