示例#1
0
        private void DoTheRun(int iterations)
        {
            Console.WriteLine("Start");
            Task[] allTasks = new Task[23];
            for (int t = 0; t < allTasks.Length; t++)
            {
                int tt = t;
                allTasks[t] = Task.Run(() =>
                {
                    var ttt = tt;
                    for (int i = 0; i < iterations; i++)
                    {
                        try
                        {
                            RunAllStressTests();
                        }
                        catch (Exception e)
                        {
                            System.Diagnostics.Debugger.Break();
                        }

                        if (i % 1000 == 0)
                        {
                            Console.WriteLine(ttt + " " + i);
                        }
                    }
                    Console.WriteLine(ttt + ": done");
                });
            }
            Task.WaitAll(allTasks);

            Console.WriteLine("Dispose all");
            StaticDisposablesHelper.DisposeAll();
        }
示例#2
0
 static RecyclablePooledFactories()
 {
     s_recyclablePooledChannelFactories = StaticDisposablesHelper.AddDisposable(
         new PoolOfThings <ChannelFactory <WcfService1.IService1> >(
             maxSize: 10,
             createInstance: () =>
             TestHelpers.CreateChannelFactory <WcfService1.IService1>(TestHelpers.CreateEndPointAddress(), TestHelpers.CreateBinding()),
             destroyInstance: (chf) =>
             s_CloseFactoryStats.CallActionAndRecordStats(() => TestHelpers.CloseFactory(chf))));
 }
示例#3
0
 static PooledFactoriesAndChannels()
 {
     s_pooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable(
         new PoolOfThings <FactoryAndPoolOfItsObjects <ChannelFactory <WcfService1.IService1>, WcfService1.IService1> >(
             maxSize: 3, // # of pooled FactoryAndPoolOfItsObjects
             createInstance: () => new FactoryAndPoolOfItsObjects <ChannelFactory <WcfService1.IService1>, WcfService1.IService1>(
                 createFactoryInstance: () =>
                 TestHelpers.CreateChannelFactory <WcfService1.IService1>(TestHelpers.CreateEndPointAddress(), TestHelpers.CreateBinding()),
                 destroyFactoryInstance: (chf) =>
                 s_CloseFactoryStats.CallActionAndRecordStats(() => TestHelpers.CloseFactory(chf)),
                 maxPooledObjects: 3, // # of pooled channels within each pooled FactoryAndPoolOfItsObjects
                 createObject: (chf) =>
                 s_CreateChannelStats.CallFuncAndRecordStats(TestHelpers.CreateChannel, chf),
                 destroyObject: (ch) =>
                 s_CloseChannelStats.CallActionAndRecordStats(() => TestHelpers.CloseChannel(ch))
                 ),
             destroyInstance: (_fapoic) => _fapoic.Destroy()));
 }
示例#4
0
 static RecyclablePooledFactoriesAndChannelsAsync_OpenOnce()
 {
     s_recyclablePooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable(
         new PoolOfAsyncThings <
             FactoryAndPoolOfItsAsyncObjects <ChannelFactory <WcfService1.IService1>, OpenAsyncOnceChannelWrapper <WcfService1.IService1> > >(
             maxSize: 3, // # of pooled FactoryAndPoolOfItsChannels
             createInstance: () => new FactoryAndPoolOfItsAsyncObjects <ChannelFactory <WcfService1.IService1>, OpenAsyncOnceChannelWrapper <WcfService1.IService1> >(
                 createFactoryInstance: () =>
                 TestHelpers.CreateChannelFactory <WcfService1.IService1>(TestHelpers.CreateEndPointAddress(), TestHelpers.CreateBinding()),
                 destroyFactoryInstanceAsync: async(chf) =>
                 await s_CloseFactoryStats.CallAsyncFuncAndRecordStatsAsync(TestHelpers.CloseFactoryAsync, chf),
                 maxPooledObjects: 3, // # of pooled channels within each pooled FactoryAndPoolOfItsAsyncObjects
                 createObject: (chf) =>
                 s_CreateChannelStats.CallFuncAndRecordStats(func: () => new OpenAsyncOnceChannelWrapper <WcfService1.IService1>(TestHelpers.CreateChannel(chf))),
                 destroyObjectAsync: async(chWr) =>
                 await s_CloseChannelStats.CallAsyncFuncAndRecordStatsAsync(func: () => TestHelpers.CloseChannelAsync(chWr.Channel))
                 ),
             destroyInstanceAsync: async(_fapoic) => await _fapoic.DestroyAsync()));
 }