Task new thread use ManualResetEvent why dotnetty stop WaitOne(), I dot not user Dotnetty thread
- Dominant language
- C#
- Stars
- 4.3k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
`
var bootstrap = new Bootstrap();
bootstrap
.Group(group)
.Channel()
.Option(ChannelOption.TcpNodelay, true)
.Handler(new ActionChannelInitializer(channel =>
{
IChannelPipeline pipeline = channel.Pipeline;
pipeline.AddLast(new NLogHandler("BDDataClientService"));
pipeline.AddLast("IdleStateHandler", new IdleStateHandler(300, 60, 300));
pipeline.AddLast("DBTerIdelStateMyHandler", new DBDataIdelStateMyHandler());
pipeline.AddLast("BeiDouFrameDecoder", new BeiDouFrameDecoder(BDFrameConst.FRAME_FLAG, BDFrameConst.FRAME_MAX_LEN, BDFrameConst.FRAME_Min_LEN));
pipeline.AddLast("BDClientBeiDouContentDecoderHandler", new BeiDouContentDecoderHandler(this._optionsMonitor));
pipeline.AddLast("BeiDouContentEncoderHandler", new BeiDouContentEncoderHandler());
pipeline.AddLast("BDClientHandler", new BDDataClientHandler());
}));
BDDataClientHandler:
public class BDDataClientHandler : ChannelHandlerAdapter
{
private readonly NLog.Logger _loggerInfo;
private readonly NLog.Logger _loggerError;
private const string jobKey = "BDDataClientHandler";
private const string triggerKey = "BDDataClientHandler";
private PlatSendMessageToTerProcessing _platSendMessageToTerProcessing;
public BDDataClientHandler()
{
_loggerInfo = NLog.LogManager.GetLogger("Info");
_loggerError = NLog.LogManager.GetLogger("");
_platSendMessageToTerProcessing = new PlatSendMessageToTerProcessing();
` _platSendMessageToTerProcessing.Start();`
}
public override void ChannelRead(IChannelHandlerContext context, object message)
{
try
{
ChannelMessage channelMessage = message as ChannelMessage;
if (channelMessage != null)
_platSendMessageToTerProcessing.PushMessage(channelMessage);
}
catch (Exception ex)
{
}
}
}
PlatSendMessageToTerProcessing
private ManualResetEvent _pmqMRE = new ManualResetEvent(false);
private void DoingWork()
{
Task.Factory.StartNew(() =>
{
while (_isWork)
{
try
{
_pmqMRE.WaitOne();
while (_platMessageQueue.Count > 0)
{
ChannelMessage channelMessage;
if (_platMessageQueue.TryDequeue(out channelMessage))
{
SendMessageToTer(channelMessage);
}
}
_pmqMRE.Reset();
}
catch (Exception ex)
{
}
}
});
}
`
_pmqMRE.WaitOne(); I dot not user Dotnetty thread,dotnetty stop there why?
thanks a lot
Contributor guide
Assessment
This issue has not been assessed yet.