读书人

an interface that was marshalled fo

发布时间: 2012-12-16 12:02:32 作者: rapoo

an interface that was marshalled for a different thread.这个exception什么意思?


刚用C#这个问题各种烦,这几天一直遇到,求大神仔细讲一下,还有怎么避免?
[解决办法]
可以详细一点啊
[解决办法]

引用:
可以详细一点啊

我建一个timer
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;

}

[解决办法]
求大神 解答呀!!!
C#我弱爆了呀
[解决办法]
我同样的代码放到button下面没问题,来人解答呀!

读书人网 >C#

热点推荐