我正在开发一个应用程序,有这样一种情况:我需要同时完成两件事,但我有点困难。我正在开发一个相机应用程序,我需要在拍照时同时触发LED灯,以获得更好的图像。以下是我尝试过的选项。
Use two threads:
Thread t1 = new Thread( new ThreadStart(() => { //trigger LED here })); Thread t2 = new Thread( new ThreadStart(() => { //trigger camera })); t1.Start(); t2.Start(); t1.Join(); t2.Join();
Trigger the light on the current thread and the camera on a separate thread
Thread t = new Thread( new ThreadStart(() => { //trigger camera })); // trigger LED t.Start(); t.Join();
在这两种情况下,在大约10张图像之后,我会得到闪烁的背景,这意味着相机和LED没有同步。我的问题是,有没有办法实现我正在尝试做的事情。
谢谢。