简体   繁体   中英

c# threading: creating a comcomponent via threading.timer and disposing of same component from a different threadingTimer instance

I have an c# app which creates and starts a directshow graph on the firing of a Threading.Timer event. some time later a different Timer instance attempts to stop and dispose the graph via Marshal.ReleaseComObject(theGraph).

This causes a threading issue and visual studio tells me that I risk data corruption by attempting to dispose of the com object (the graph in this case) from a different thread other than the one it was created on.

How do I get back onto the original thread to stop and dispose the graph?

I know very little about threading and I've been ignoring the issue, but I have some time now to learn more about threading and how I should make correct use of it.

any pointer most welcome.

我在这里找到了解决问题的方法: http : //www.codeproject.com/Articles/12082/A-DelegateQueue-Class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM