本文整理汇总了C#中SignalR.Hosting.Memory.MemoryHost.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryHost.Dispose方法的具体用法?C# MemoryHost.Dispose怎么用?C# MemoryHost.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SignalR.Hosting.Memory.MemoryHost
的用法示例。
在下文中一共展示了MemoryHost.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StressGroups
public static void StressGroups()
{
var host = new MemoryHost();
host.MapHubs();
int max = 15;
var countDown = new CountDown(max);
var list = Enumerable.Range(0, max).ToList();
var connection = new Client.Hubs.HubConnection("http://foo");
var proxy = connection.CreateProxy("MultGroupHub");
proxy.On<int>("Do", i =>
{
lock (list)
{
if (!list.Remove(i))
{
Debugger.Break();
}
}
countDown.Dec();
});
try
{
connection.Start(new Client.Transports.ServerSentEventsTransport(host)).Wait();
for (int i = 0; i < max; i++)
{
proxy.Invoke("Do", i).Wait();
}
if (!countDown.Wait(TimeSpan.FromSeconds(10)))
{
Console.WriteLine("Didn't receive " + max + " messages. Got " + (max - countDown.Count) + " missed (" + String.Join(",", list.Select(i => i.ToString())) + ")");
var bus = host.DependencyResolver.Resolve<INewMessageBus>();
Debugger.Break();
}
}
finally
{
connection.Stop();
host.Dispose();
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
示例2: StressGroups
public static void StressGroups()
{
var host = new MemoryHost();
host.HubPipeline.EnableAutoRejoiningGroups();
host.MapHubs();
int max = 15;
var countDown = new CountDown(max);
var list = Enumerable.Range(0, max).ToList();
var connection = new Client.Hubs.HubConnection("http://foo");
var proxy = connection.CreateProxy("MultGroupHub");
var bus = (MessageBus)host.DependencyResolver.Resolve<IMessageBus>();
proxy.On<int>("Do", i =>
{
lock (list)
{
if (!list.Remove(i))
{
Debugger.Break();
}
}
countDown.Dec();
});
try
{
connection.Start(host).Wait();
for (int i = 0; i < max; i++)
{
proxy.Invoke("Do", i).Wait();
}
int retry = 3;
bool result = false;
do
{
result = countDown.Wait(TimeSpan.FromSeconds(10));
if (!result)
{
Console.WriteLine("Didn't receive " + max + " messages. Got " + (max - countDown.Count) + " missed (" + String.Join(",", list.Select(i => i.ToString())) + ")");
Console.WriteLine("A=" + bus.AllocatedWorkers + " B=" + bus.BusyWorkers);
countDown.Reset();
}
retry--;
} while (retry > 0);
if (!result)
{
Console.WriteLine("A=" + bus.AllocatedWorkers + " B=" + bus.BusyWorkers);
Debugger.Break();
}
}
finally
{
connection.Stop();
host.Dispose();
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
示例3: ReconnectFiresAfterHostShutDown
public void ReconnectFiresAfterHostShutDown()
{
var host = new MemoryHost();
var conn = new MyReconnect();
host.DependencyResolver.Register(typeof(MyReconnect), () => conn);
host.MapConnection<MyReconnect>("/endpoint");
var connection = new Client.Connection("http://foo/endpoint");
connection.Start(host).Wait();
host.Dispose();
Thread.Sleep(TimeSpan.FromSeconds(5));
Assert.Equal(Client.ConnectionState.Reconnecting, connection.State);
connection.Stop();
}