I am using Canon SDK Example of Mr. Johannes Bildstein EDSDKLib but I am getting Argument Exception with Message "The delegate must have only one target."
When I dig through I found MainThread.Invoke(() =>
of TakePhotoShutterAsync()
method is throwing exception. Kindly advise how I can fix this.
Below is my Stack Trace
at EOSDigital.API.GeneralExceptionHandler.BeginInvoke(Object sender, Exception ex, AsyncCallback callback, Object object)
at EOSDigital.API.ErrorHandler.ReportError(Object sender, Exception ex)
at EOSDigital.API.Camera.<TakePhotoShutterAsync>b__80_0(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Below is full method where I am getting exception.
/// <summary>
/// Takes a photo with the current camera settings asynchronously with the PressShutterButton command
/// </summary>
/// <exception cref="ObjectDisposedException">Camera is disposed</exception>
/// <exception cref="CameraSessionException">Session is closed</exception>
/// <exception cref="SDKStateException">Canon SDK is not initialized</exception>
public void TakePhotoShutterAsync()
{
CheckState();
ThreadPool.QueueUserWorkItem((state) =>
{
try
{
MainThread.Invoke(() =>
{
SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.Completely);
SendCommand(CameraCommand.PressShutterButton, (int)ShutterButton.OFF);
});
}
catch (Exception ex) { err.writeError(ex.Message); if (!ErrorHandler.ReportError(this, ex)) throw; }
});
}