Page 1 of 1
Acquire on a separate thread
Posted: Mon Oct 01, 2012 11:46 am
by EbenRoux
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
Re: Acquire on a separate thread
Posted: Wed Oct 03, 2012 8:23 am
by Alex
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
Re: Acquire on a separate thread
Posted: Wed Oct 03, 2012 11:31 am
by EbenRoux
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
Re: Acquire on a separate thread
Posted: Fri Oct 05, 2012 8:14 am
by Alex
Hello Eben,
My question actually relates to the 'Aquire' method (not AquireModal). Is it possible to run *that* on a separate thread?
Acquire method also can be used when you acquire image(s) in the background thread. Do you have any problems?
Best regards, Alexander
Re: Acquire on a separate thread
Posted: Fri Oct 05, 2012 1:40 pm
by EbenRoux
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
Re: Acquire on a separate thread
Posted: Mon Oct 15, 2012 11:42 am
by EbenRoux
Any feedback yet?
Re: Acquire on a separate thread
Posted: Thu Oct 18, 2012 4:37 pm
by Alex
Hello Eben,
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");
}
Best regards, Alexander