COM execution as backgroung in WPF without hanging UI
<p>I am calling COM dll in WPF and want that UI doesn't Hang.
So far i have used  Task.Run  approaches but no result.</p>

<p>Here is the code</p>

<pre><code>   public MainWindow()
        {
            InitializeComponent();

            Task.Run(() =&gt; DoWork());

        }


 private  void DoWork()
    {

         Task.Run(() =&gt;
        {
            Allocate();

        });

    }



 void Allocate()
        {

            int idwErrorCode = 0;


            try
            {  
                bIsConnected = axCZKEM1.Connect_Net("192.168,2,2", 3703);


            }
</code></pre>

<p>the COM method  <strong>axCZKEM1.Connect_Net("192.168,2,2", 3703)</strong> execution takes time and UI hangs up. </p>

<p>Need a simple solution.</p>