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
| public class Foo { | |
| //public void Bah() { | |
| // | |
| //} | |
| public void Work() { | |
| } | |
| } |
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
| builder.RegisterType<TestMessageHandler>(); | |
| builder.Register(c => | |
| ServiceBusFactory.New(sbc => | |
| { | |
| var ctx = c.Resolve<IComponentContext>(); | |
| sbc.UseMsmq(); | |
| sbc.UseMulticastSubscriptionClient(); | |
| sbc.VerifyMsmqConfiguration(); |
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
| public static void Main(string[] args) | |
| { | |
| var builder = new ContainerBuilder(); | |
| // Register our service bus, this could probably be a module. | |
| builder.Register(c => | |
| ServiceBusFactory.New(sbc => | |
| { | |
| var scope = c.Resolve<ILifetimeScope>(); |
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
| public void Start() | |
| { | |
| while(true) | |
| { | |
| using(var scope = _scope.BeginLifetimeScope()) | |
| { | |
| var service = scope.Resolve<IWorkItemService>(); | |
| var workItem = service.GetNextWorkItem(); | |
| if (workItem != null) |
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
| public Task<WorkItemDispatchResult> DispatchWorkItem(DateTime now, WorkItem dbWorkItem) | |
| { | |
| return new Task<WorkItemDispatchResult>(() => | |
| { | |
| try | |
| { | |
| var workItem = dbWorkItem.DeserializeWorkItemData(); | |
| _log.Debug("Dispatching work item: {0}, work-item type: {1}, dispatch attempts: {2}.", dbWorkItem.Id, workItem.GetType().FullName, dbWorkItem.NumberOfDispatchAttempts); |
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
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| Parallel.ForEach(Enumerable.Range(0, 1000000000), i => Task.Factory.StartNew(() => Console.WriteLine(i))); | |
| } | |
| } |
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
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| for (var i = 0; i < 1000000000; i++) | |
| { | |
| int i1 = i; | |
| Task.Factory.StartNew(() => Console.WriteLine(i1)); | |
| } |
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
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var store = new DocumentStore { Url = "http://localhost:8080" }.Initialize(); | |
| try | |
| { | |
| var sw = Stopwatch.StartNew(); | |
| Parallel.ForEach(Enumerable.Range(0, 10000), i => |
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
| var container = new Container(); | |
| container.Register(c => new Foo()).As(typeof(IFoo)); | |
| container.Register(c => | |
| { | |
| var foo = (IFoo) c.Resolve(typeof (IFoo)); | |
| return new Bah(foo); | |
| }).As(typeof(IBah)); |
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
| [Test] | |
| public void Foo() | |
| { | |
| var initialList = new List<int>(); | |
| var list1 = new List<int>(); | |
| var list2 = new List<int>(); | |
| for(var i = 0; i < 100000; i++) | |
| { | |
| initialList.Add(i); |