I have a method that runs some tasks in the background called backgroundworker5_doWork(). This method call the Invoke instruction which helps me to access the controls on my windows form (since a control cannot be accessed from another thread normally) as such
 private void backgroundWorker5_DoWork(object sender, DoWorkEventArgs e)
    {
        if(!isAdmin)
        {             
            //Start of invoke instruction   
            Invoke(new Action(() =>
            {
                if(test)
                {
                    return;
                }
                if (ValidateAll())
                {
                    comboBox5.Items.Clear();
                    packageToSendList.Clear();
                    progressBar3.Visible = true;
                    Cursor.Current = Cursors.WaitCursor;
                }
            }));
            //End of invoke
            RunAfterInvokeMethod() //Instructions called after the invoke 
       }
   }
My issue is that when true, the return instruction exits the invoke block (rightfully so) and executes the RunAfterInvokeMethod() which is not what I want. What I want is to exit the backgroundWorker5_doWork() method after the return is called.
I understand that it only exits the invoke instruction but is it possible to make it exit the parent method as well ? Maybe using other instructions ?
Thanks !
 
     
     
     
    