Skip to content

Instantly share code, notes, and snippets.

@flq
Created September 20, 2013 15:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save flq/6638867 to your computer and use it in GitHub Desktop.
Save flq/6638867 to your computer and use it in GitHub Desktop.
Example setup for Membus to dispatch messages of a certain kind onto the UI thread...
// Use like BusSetup.StartWith<Conservative>().Apply<UiMessages>().Construct();
internal class UiMessages : ISetup<IConfigurableBus>
{
void ISetup<IConfigurableBus>.Accept(IConfigurableBus setup)
{
setup.ConfigurePublishing(obj =>
{
obj.MessageMatch(mi => mi.IsType<IUIMsg>()).PublishPipeline(new UiMsgDispatcher());
});
}
private class UiMsgDispatcher : IPublishPipelineMember
{
private readonly SequentialPublisher _seq = new SequentialPublisher();
public void LookAt(PublishToken token)
{
Dispatcher.CurrentDispatcher.EnsureActionOnDispatcher(() => _seq.LookAt(token));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment