Skip to content

Instantly share code, notes, and snippets.

@kthompson
Created May 26, 2011 21:20
Show Gist options
  • Save kthompson/994113 to your computer and use it in GitHub Desktop.
Save kthompson/994113 to your computer and use it in GitHub Desktop.
Utilities Module Messaging
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