logging most communication exceptions
This commit is contained in:
parent
d61d207fb8
commit
ef2ddd16bf
6 changed files with 80 additions and 40 deletions
|
@ -1,40 +1,50 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Channels;
|
||||
using Exceptionless;
|
||||
using Exceptionless.Models;
|
||||
|
||||
namespace Sledgemapper
|
||||
{
|
||||
public class ChannelsQueue
|
||||
{
|
||||
private readonly ChannelWriter<Action> _writer;
|
||||
|
||||
public ChannelsQueue()
|
||||
public class ChannelsQueue
|
||||
{
|
||||
var channel = Channel.CreateUnbounded<Action>(new UnboundedChannelOptions() { SingleReader = true });
|
||||
var reader = channel.Reader;
|
||||
_writer = channel.Writer;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while (await reader.WaitToReadAsync())
|
||||
private readonly ChannelWriter<Action> _writer;
|
||||
|
||||
public ChannelsQueue()
|
||||
{
|
||||
var channel = Channel.CreateUnbounded<Action>(new UnboundedChannelOptions() { SingleReader = true });
|
||||
var reader = channel.Reader;
|
||||
_writer = channel.Writer;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while (await reader.WaitToReadAsync())
|
||||
{
|
||||
// Fast loop around available jobs
|
||||
while (reader.TryRead(out var job))
|
||||
{
|
||||
job.Invoke();
|
||||
{
|
||||
try
|
||||
{
|
||||
job.Invoke();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExceptionlessClient.Default.SubmitException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Enqueue(Action job)
|
||||
{
|
||||
_writer.TryWrite(job);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_writer.Complete();
|
||||
});
|
||||
}
|
||||
|
||||
public void Enqueue(Action job)
|
||||
{
|
||||
_writer.TryWrite(job);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_writer.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue