110,534
社区成员
发帖
与我相关
我的任务
分享
TimerHandle = new TimerElapsedHandler(MyTimer);
timespace = TimeSpan.FromMilliseconds(5000); //设定的Timer时间(毫秒)
DelayTimer = ThreadPoolTimer.CreatePeriodicTimer(TimerHandle, timespace);
如果时间长,如5000ms就会在new WriteableBitmap跳出这个异常。
如果时间设置短 就会在await m_mediaCaptureMgr.CapturePhotoToStreamAsync(_encodingProps, _imageStream);这儿异常。
private async void MyTimer(ThreadPoolTimer timer)
{
_imageStream = new InMemoryRandomAccessStream();
await m_mediaCaptureMgr.CapturePhotoToStreamAsync(_encodingProps, _imageStream);
await _imageStream.FlushAsync();
bitmap = new WriteableBitmap(300, 200);
_imageStream.Seek(0);
bitmap.SetSource(_imageStream);
image.Source = bitmap;
}