Hello,
We will eventually be running our software on a central server that talks to multiple MFPs.
Is it possible to scan using Aquire on a separate thread? From what I can tell from another post along similar lines is that Aquire requires a UI thread?
Regards,
Eben
Acquire on a separate thread
Moderator: Alex
Re: Acquire on a separate thread
Hello Eben,
Yes, you can acquire image from scanner in a separate thread. Please see this topic: viewtopic.php?f=5&t=1560
Best regards, Alexander
Yes, you can acquire image from scanner in a separate thread. Please see this topic: viewtopic.php?f=5&t=1560
Best regards, Alexander
Re: Acquire on a separate thread
Hi Alex,
Yip, doing that already (AquireModal). Works OK.
My question actually relates to the 'Aquire' method (not AquireModal). Is it possible to run *that* on a separate thread?
Regards,
Eben
Yip, doing that already (AquireModal). Works OK.
My question actually relates to the 'Aquire' method (not AquireModal). Is it possible to run *that* on a separate thread?
Regards,
Eben
Re: Acquire on a separate thread
Hello Eben,
Best regards, Alexander
Acquire method also can be used when you acquire image(s) in the background thread. Do you have any problems?My question actually relates to the 'Aquire' method (not AquireModal). Is it possible to run *that* on a separate thread?
Best regards, Alexander
Re: Acquire on a separate thread
Hi Alex,
I start a new thread (T2) from my main console thread (T1) and then create all the objects on T2 and call Aquire. But nothing happens after that. I let T1 spin since I need to wait for the scanning to complete but no scanning takes place.
Do you have a sample of this somewhere?
Regards,
Eben
I start a new thread (T2) from my main console thread (T1) and then create all the objects on T2 and call Aquire. But nothing happens after that. I let T1 spin since I need to wait for the scanning to complete but no scanning takes place.
Do you have a sample of this somewhere?
Regards,
Eben
Re: Acquire on a separate thread
Any feedback yet?
Re: Acquire on a separate thread
Hello Eben,
Sorry for a delay.
How your second thread waits while the image acquisition is finished?
Here is a snippet of correct code:
Best regards, Alexander
Sorry for a delay.
How your second thread waits while the image acquisition is finished?
Here is a snippet of correct code:
Code: Select all
[STAThread]
static void Main(string[] args)
{
Thread thread1 = new Thread(AcquireImageFromDevice);
thread1.Start();
while (thread1.IsAlive)
{
Thread.Sleep(10);
}
}
private void AcquireImageFromDevice()
{
using (DeviceManager deviceManager = new DeviceManager())
{
deviceManager.Open();
...
device.ImageAcquired += new EventHandler<ImageAcquiredEventArgs>(device_ImageAcquired);
device.Acquire();
while (device.State != DeviceState.Opened)
{
System.Windows.Forms.Application.DoEvents();
}
device.ImageAcquired -= new EventHandler<ImageAcquiredEventArgs>(device_ImageAcquired);
}
}
private void device_ImageAcquired(object sender, ImageAcquiredEventArgs e)
{
Console.WriteLine("Image is acquired");
}