Message queue for cross thread sync public class WmSync : IDisposable
{
    public WmSync()
    {
        var sync = new Control();
        sync.Handle.GetHashCode(); // ensure handle is created
        _sync = sync;
        Thread.MemoryBarrier();
    }

    public void Dispose()
    {
        _sync.Dispose();
    }

    public void BeginInvoke(Action action)
    {
        _sync.BeginInvoke(action);
    }

    public void Invoke(Action action)
    {
        _sync.Invoke(action);
    }

    public bool InvokeRequired
    {
        get { return _sync.InvokeRequired; }
    }

    private readonly Control _sync;
}


The idea is to create this object in the main thread and use it from background threads to execute pieces of code in the main thread.

For example:

// somewhere in the very beginning of the program, in the main thread
static WmSync SyncQueue = new WmSync();

// somewhere in a background thread
SyncQueue.Invoke(
    () =&gt;
    {
        if (_settingsForm != null)
            _settingsForm.Show();
    });


This is just an artificial sample, but it should give you idea. Is this code thread safe?
Thread.MemoryBarrier()
What do you expect the call to Thread.MemoryBarrier() will help your code ?
What does Thread.MemoryBarrier do ? It prevents that the compiler and the hardware subtly transform a program’s memory operations.
So basically for your code it ensures that then following instructions will be executed in the order they are written.

var sync = new Control();
sync.Handle.GetHashCode(); // ensure handle is created
_sync = sync;  


Thread safety
To answer &quot;Is this code thread safe ?&quot;, you first need to set your definition of thread safety aka what does thread safety means for you. See also what-is-this-thing-you-call-thread-safe
General

the code is lacking a EndInvoke() which should be integrated.

you are misusing a Control to access the main (ui) thread of an application.

wouldn't a SynchronizationContext be a better fit here ?
See also: https://stackoverflow.com/a/20300351/2655508