main
 1using System;
 2using System.Threading;
 3using gorilla.commons.utility;
 4
 5namespace momoney.service.infrastructure.threading
 6{
 7    public interface ISynchronizedCommand : ParameterizedCommand<Action>, ParameterizedCommand<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(Action item)
19        {
20            context.Post(x => item(), new object());
21        }
22
23        public void run(Command item)
24        {
25            run(item.run);
26        }
27    }
28}