Parameters
- runAction
- The action to be run on an STA thread after the COM security is initialized.
The value of this parameter cannot be
null
(Nothing
in Visual Basic).
The value of this parameter cannot be null
(Nothing
in Visual Basic).
The value of this parameter cannot be null
(Nothing
in Visual Basic).
Exception | Description |
---|---|
System.ArgumentNullException |
A This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception. |
System.Exception | An error has occurred during application execution. |
System.OutOfMemoryException | Thrown when there is not enough memory to continue the execution of a program. |
System.PlatformNotSupportedException | The feature does not run on a particular platform. |
System.Threading.ThreadInterruptedException | Thrown when a System.Threading.Thread is interrupted while it is in a waiting state. |
This method can be used in programs that were originally designed to run on an STA thread, but had to be switched to an MTA thread in order to prevent premature COM security initialization. The method assures the COM security initialization using the AssureSecurityInitialization method, and then runs the specified runAction on an STA thread. The current thread is used, if it already is an STA thread; otherwise, a dedicated thread is created for the runAction execution, and its apartment state is set to STA. In both cases, the control returns to the caller after the runAction has completed. The runAction takes a single argument, which is the result of the COM security initialization, as returned by the AssureSecurityInitialization method call.
The runAction is executed even when the COM security initialization fails.