Class ComWrapper<T>
Wrapper over COM interop for marshalling objects. It is used to give access to COM objects from any thread
Implements
Namespace: CAMAPI.DotnetHelper
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 |
---|---|---|
Int |
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
Type | Description |
---|---|
T |
It
Instance but with additional null reference check.
Declaration
public T It { get; }
Property Value
Type | Description |
---|---|
T |
Methods
Dispose()
Clean up resources
Declaration
public void Dispose()
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<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 | Description |
---|---|
T1 |
Type Parameters
Name | Description |
---|---|
T1 |