Home:ALL Converter>Get the backgroundworker from MainForm in a user control

Get the backgroundworker from MainForm in a user control

Ask Time:2018-09-21T21:52:04         Author:calarez

Json Formatter

I have a form with a backgroundworker when I click a button the backgroundworker starts with this code:

private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
     M_Results m_Results = new M_Results();
     this.Controls.Add(m_Results);
     m_Results.Location = new Point(0, 0);
     m_Results.Visible = true;
}

in the user control Im trying to reporteprogress from the backgroundworker, what Ive done is:

   BackgroundWorker bgWorker;
   public Results()
   {
        Form mainform = this.Parent as Form;
        bgWorker = Padre.Controls["backgroundWorker"] as BackgroundWorker;
        InitializeComponent();
        Inicializartablas();
        Formatotablas();
   }

but I get error that I cant convert Form.control to backgroundworker.

thank you Carlos

Author:calarez,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/52445248/get-the-backgroundworker-from-mainform-in-a-user-control
yy