You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System;
using StackExchange.Redis;
class Publisher
{
static void Main()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("172.16.1.50");
ISubscriber pub = redis.GetSubscriber();
while (true)
{
pub.Publish(RedisChannel.Literal("channel1"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
}
}
}
sub:
using System;
using System.Threading;
using System.Threading.Tasks;
using StackExchange.Redis;
class Subscriber
{
static int id = 0;
//[System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.NoOptimization)]
static void Main()
{
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("172.16.1.50");
ISubscriber sub = redis.GetSubscriber();
Task.Run(async () => await sub.SubscribeAsync(RedisChannel.Literal("channel1"), HandleMessage));
while (true)
{
Thread.Sleep(1000);
}
}
static void HandleMessage(RedisChannel channel, RedisValue message)
{
Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + $" id:{id++} Received from {channel}: {message}");
}
}
run in debug mode ,all fine!
but run in release mode, after a while,the sub program is freeze.
I add [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.NoOptimization)] to Main(),run fine.
I dont know why... I need help,thx!
The text was updated successfully, but these errors were encountered:
I'd advise taking a memory dump here to see what's happening, the best way to investigate what the freeze is would be to inspect the dump (Visual Studio is good for this, as I see in your screenshot used) and use the Debug > Windows > Threads view to see what they're stalled on.
pub:
sub:
run in debug mode ,all fine!
but run in release mode, after a while,the sub program is freeze.
I add [System.Runtime.CompilerServices.MethodImpl(MethodImplOptions.NoOptimization)] to Main(),run fine.
I dont know why... I need help,thx!
The text was updated successfully, but these errors were encountered: