-
-
Save dterracino/912171ec49b8428c3251516da54fbc47 to your computer and use it in GitHub Desktop.
Example setup for Membus to dispatch messages of a certain kind onto the UI thread...
This file contains hidden or 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
// 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