recently I have been moving more of SharpCap's internals to an asynchronous programming model (async/await in C#, roughly equivalent to promises in Javascript, etc). If you look at the methods available on the camera object, you will see more 'Async' methods - for instance
Code: Select all
RunCaptureAsync(self: Camera, cancellationToken: CancellationToken) -> Task
CaptureSingleFrameToAsync(self: Camera, filepath: str, allowPreviousFrame: bool) -> Task[FrameCaptureResult]
TakeFramingShotAsync(self: Camera, cancellationToken: CancellationToken) -> Task
If you just want to start the action and don't care about completion, feel free to use the Async methods and ignore the return value. You will need to add an import so that you can access the CancellationToken type:
Code: Select all
from System.Threading import CancellationToken
SharpCap.SelectedCamera.TakeFramingShotAsync(CancellationToken.None)
If you must call an Async method and get code to run after completion, you need to use 'ContinueWith' to schedule your follow on code after the asynchronous method completes - a bit like this
Code: Select all
from System.Threading.Tasks import Task
from System.Threading import CancellationToken
from System import Action
def close(t):
SharpCap.SelectedCamera = None
SharpCap.SelectedCamera.TakeFramingShotAsync(CancellationToken.None).ContinueWith(Action[Task](close))
hope this helps,
Robin