main
1using System;
2using System.Threading;
3using gorilla.commons.utility;
4
5namespace gorilla.commons.infrastructure.threading
6{
7 public interface ISynchronizedCommand : Command<Action>, Command<Command> {}
8
9 public class SynchronizedCommand : ISynchronizedCommand
10 {
11 readonly SynchronizationContext context;
12
13 public SynchronizedCommand(SynchronizationContext context)
14 {
15 this.context = context;
16 }
17
18 public void run_against(Action item)
19 {
20 context.Post(x => item(), new object());
21 }
22
23 public void run_against(Command item)
24 {
25 run_against(item.run);
26 }
27 }
28}