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

easyrem 2012-11-22 05:07:49


刚用C#这个问题各种烦,这几天一直遇到,求大神仔细讲一下,还有怎么避免?
...全文
202 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
easyrem 2012-11-23
  • 打赏
  • 举报
回复
我同样的代码放到button下面没问题,来人解答呀!
easyrem 2012-11-22
  • 打赏
  • 举报
回复
求大神 解答呀!!! C#我弱爆了呀
easyrem 2012-11-22
  • 打赏
  • 举报
回复
引用 1 楼 eightyao 的回复:
可以详细一点啊
我建一个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;
            
        }
ZpSoft_wlp 2012-11-22
  • 打赏
  • 举报
回复
可以详细一点啊

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧