public void ComChunkerWorksOnThreading() { Thread.CurrentThread.GetApartmentState().Should().Be(ApartmentState.MTA); var chunker = new ComChunker(ChunkerConfiguration.Default); Task.Run(() => { using var session = chunker.BeginChunking(chunk => { }); session.PushBuffer(new ArraySegment <byte>(new byte[1])); }).GetAwaiter().GetResult(); }
public void ComChunkerWorksOnThreading() { // For some reason current thread is STAThread, so we need to start a new one. var thread = new Thread(() => { Thread.CurrentThread.GetApartmentState().Should().Be(ApartmentState.MTA); var chunker = new ComChunker(); Task.Run(() => { using var session = chunker.BeginChunking(chunk => { }); session.PushBuffer(new ArraySegment <byte>(new byte[1])); }).GetAwaiter().GetResult(); }); thread.Start(); thread.Join(); }