multithreading - TimerCallback Delegate to drive an STA model .NET library component -
I use the timer callback rep mechanism to run instances of objects from a third party .NET library component on different threads. I am trying to Executed on a timely basis.
When I try to make an example of an object from the library, an exception is raised:
(The name of the object) can only be called < / P>
>
Single-threaded COM components have a tough requirement that you create on the STA thread. By using the [STAThread] attribute on your main () method and you create a message by pumping the loop. Such as the application made by the app. Like that. ().
Now you can call such a component from an employee thread or timer callback. COM ensures that the single-threaded requirement is met for the component and the martial who calls the STA thread. Losing all that you were trying to accomplish, all the components of the component move on only one thread. You will slow it down, not fast. Marshalling the call not is fast.
There is no secret sauce here, you can not magically change the component that is explicitly said that it does not support threading in a threaded component. Nor is it unusual, the vast majority of COM components, or for that matter NET components do not support threading. The difference between COM and .NET components is that COM does something about it. An NATT component will usually get a failure without any diagnostics on the thread running.
Comments
Post a Comment