Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a function from the main thread and making it work in parallel with a function in the main thread
    text
    copied!<p>I really need your help in my issue very quickly and it's too close to the previous issue. I want to call a function using thread from the main thread.</p> <p>for more explanaition, here is a sample from my code: // please look to the code begining from ( //------- ) </p> <pre><code> // this function is being called from the Form1 class Like this //(this.Load += new System.EventHandler(this.Form1_Load);) private void Form1_Load(object sender, EventArgs e) { Common.MainForm = this; ftpServerIP = "74.220.215.77/ASGAQuraan"; ftpUserID = "sanbouk@asgatech.com"; ftpPassword = "asga_root"; iStartConnection = true; iGetNarratorData = false; iGetNarratorsSuras = false; _isExpandedIndecies = new string[10]; refreshPhons = true; count = 0; _btnDownload2PC.Enabled = false; _btnDownload2Phone.Enabled = false; //-------------------------------------------------------------------------------------- //timer1.Tick() is a function which Gets Data rom Phone //Now, GetFromServer, and GetFromPC are 2 functions which i want to them // to work in paralel with Timer1.Tick() //So, Fincally i want all 3 function work together with no gabs Timer1.Enabled = true; Timer1.Start(); if (InvokeRequired) { Invoke(new GetFromServerHandler(GetFromServer)); } else { ServerQuranTreeView.Nodes.Clear(); GetFromServer(); GetFromPC(); } } </code></pre> <p>** NOTE: in GetFromServer and GetFromPC I will update on a Tree which is in the main thread Form1 (GUI) and when when I tried to use thread ( thread _t = new Thread(new ThreadStart(GetFromServer))) this error appears: " Action being performed on this control is being called from the wrong thread. Marshal to the correct thread using Control.Invoke or Control.BeginInvoke to perform this action. " **</p> <p>I hope that I explained my problem well.</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload