Class ComWrapper<T>
Wrapper over COM interop for marshalling objects. It is used to give access to COM objects from any thread
Inheritance
ComWrapper<T>
Assembly: CAMAPI.DotnetHelper.dll
Syntax
public class ComWrapper<T> : Object, IDisposable
Type Parameters
Name |
Description |
T |
Any COM object
|
Constructors
ComWrapper(nint)
Create wrapper for COM object
Declaration
public ComWrapper(nint objPointer)
Parameters
Type |
Name |
Description |
IntPtr |
objPointer |
Pointer to COM object
|
ComWrapper(T?)
Create wrapper for COM object
Declaration
public ComWrapper(T? comObject)
Parameters
Type |
Name |
Description |
T |
comObject |
Object that implements COM interface
|
Properties
Instance
Copy of COM-object, which is accessible from any thread. It is thread-safe, but
requires additional resources to store objects for each thread
Declaration
public T? Instance { get; }
Property Value
It
Instance but with additional null reference check.
Declaration
Property Value
Methods
Dispose()
Declaration
Invoke(Action<T>)
Code to executed with current COM-object. Code will be executed in sub thread with
MTA apartment state - this will work for all COM-objects, but it should be
created also from thread with MTA apartment state
Declaration
public void Invoke(Action<T> action)
Parameters
Type |
Name |
Description |
Action<T> |
action |
|
Invoke(Func<T, TResultStatus>)
Code to executed with current COM-object. Code will be executed in sub thread with
MTA apartment state - this will work for all COM-objects, but it should be
created also from thread with MTA apartment state
Declaration
public void Invoke(Func<T, TResultStatus> actionWithStatus)
Parameters
InvokeAndWrap<TResult>(Func<T, (TResult, TResultStatus)>)
Code to executed with current COM-object. Code will be executed in sub thread with
MTA apartment state - this will work for all COM-objects, but it should be
created also from thread with MTA apartment state.
Controls if the result of action is successful or not to throw it. Create COM wrapper
for result of action
Declaration
public ComWrapper<TResult> InvokeAndWrap<TResult>(Func<T, (TResult, TResultStatus)> func) where TResult : class
Parameters
Returns
Type Parameters
InvokeAndWrap<TResult>(Func<T, TResult>)
Code to executed with current COM-object. Code will be executed in sub thread with
MTA apartment state - this will work for all COM-objects, but it should be
created also from thread with MTA apartment state.
Create COM wrapper for result of action
Declaration
public ComWrapper<TResult> InvokeAndWrap<TResult>(Func<T, TResult> func) where TResult : class
Parameters
Type |
Name |
Description |
Func<T, TResult> |
func |
|
Returns
Type Parameters
Invoke<TReturn>(Func<T, (TReturn, TResultStatus)>)
Code to executed with current COM-object. Code will be executed in sub thread with
MTA apartment state - this will work for all COM-objects, but it should be
created also from thread with MTA apartment state.
Controls if the result of action is successful or not to throw it
Declaration
public TReturn Invoke<TReturn>(Func<T, (TReturn, TResultStatus)> func)
Parameters
Returns
Type Parameters
Invoke<T1>(Func<T, T1>)
Code to executed with current COM-object. Code will be executed in sub thread with
MTA apartment state - this will work for all COM-objects, but it should be
created also from thread with MTA apartment state.
Special method to return result of action
Declaration
public T1 Invoke<T1>(Func<T, T1> func)
Parameters
Type |
Name |
Description |
Func<T, T1> |
func |
|
Returns
Type Parameters
Implements
System.IDisposable