mirror of
https://github.com/soukoku/ntwain.git
synced 2025-10-25 10:59:03 +08:00
Updated comments on sync context.
This commit is contained in:
@@ -61,42 +61,38 @@ namespace Tester.Winform
|
||||
_twain.SynchronizationContext = SynchronizationContext.Current;
|
||||
_twain.StateChanged += (s, e) =>
|
||||
{
|
||||
Debug.WriteLine("State change on thread " + Thread.CurrentThread.ManagedThreadId);
|
||||
//this.BeginInvoke(new Action(() =>
|
||||
//{
|
||||
// Debug.WriteLine("State change marshaled to thread " + Thread.CurrentThread.ManagedThreadId);
|
||||
//}));
|
||||
Debug.WriteLine("State changed to " + _twain.State + " on thread " + Thread.CurrentThread.ManagedThreadId);
|
||||
};
|
||||
_twain.DataTransferred += (s, e) =>
|
||||
{
|
||||
//this.Invoke(new Action(() =>
|
||||
//{
|
||||
if (pictureBox1.Image != null)
|
||||
{
|
||||
pictureBox1.Image.Dispose();
|
||||
pictureBox1.Image = null;
|
||||
}
|
||||
if (e.NativeData != IntPtr.Zero)
|
||||
{
|
||||
var img = e.NativeData.GetDrawingBitmap();
|
||||
if (img != null)
|
||||
pictureBox1.Image = img;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(e.FileDataPath))
|
||||
{
|
||||
var img = new Bitmap(e.FileDataPath);
|
||||
if (pictureBox1.Image != null)
|
||||
{
|
||||
pictureBox1.Image.Dispose();
|
||||
pictureBox1.Image = null;
|
||||
}
|
||||
if (e.NativeData != IntPtr.Zero)
|
||||
{
|
||||
var img = e.NativeData.GetDrawingBitmap();
|
||||
if (img != null)
|
||||
pictureBox1.Image = img;
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(e.FileDataPath))
|
||||
{
|
||||
var img = new Bitmap(e.FileDataPath);
|
||||
pictureBox1.Image = img;
|
||||
}
|
||||
//}));
|
||||
};
|
||||
_twain.SourceDisabled += (s, e) =>
|
||||
{
|
||||
//this.Invoke(new Action(() =>
|
||||
//{
|
||||
btnStopScan.Enabled = false;
|
||||
btnStartCapture.Enabled = true;
|
||||
panelOptions.Enabled = true;
|
||||
LoadSourceCaps();
|
||||
btnStopScan.Enabled = false;
|
||||
btnStartCapture.Enabled = true;
|
||||
panelOptions.Enabled = true;
|
||||
LoadSourceCaps();
|
||||
//}));
|
||||
};
|
||||
_twain.TransferReady += (s, e) =>
|
||||
|
||||
Reference in New Issue
Block a user