I have 2 Forms, in Form1 , there are  a lot of transaction to be done, so i have used the BackgroundWorker. so during the action to be taken i want the form2 to be opened and shows the progressbar ( the progress of the actions ) so I have done like this:  This is Form1  public partial class Form1 : Form {     Form2 form2 = new Form2();     public Form1()     {         InitializeComponent();         Shown += new EventHandler(Form1_Shown);          // To report progress from the background worker we need to set this property         backgroundWorker1.WorkerReportsProgress = true;         // This event will be raised on the worker thread when the worker starts         backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);         // This event will be raised when we call ReportProgress         backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);     }      void Form1_Shown(object sender, EventArgs e)     {         form2.Show();         // Start the background worker         backgroundWorker1.RunWorkerAsync();      }       private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)     {         // Your background task goes here         for (int i = 0; i &lt;= 100; i++)         {             // Report progress to 'UI' thread             backgroundWorker1.ReportProgress(i);             // Simulate long task             System.Threading.Thread.Sleep(100);         }         form2.Close();     }       private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)     {         // The progress percentage is a property of e         form2.progressBar1.Value = e.ProgressPercentage;     } }   I have a Progressbar in form2 which its modifier is public. the problem is that when the actions would be accompilshed the form2 ( which contans the progress bar) should be closed , So i used      form2.Close();   but i get this error message    Cross-thread operation not valid: Control 'Form2' accessed from a thread other than the thread it was created on   how can i solve this problem?
I have a scenario. (Windows Forms, C#, .NET)   There is a main form which hosts some user control. The user control does some heavy data operation, such that if I directly call the UserControl_Load method the UI become nonresponsive for the duration for load method execution. To overcome this I load data on different thread (trying to change existing code as little as I can)   I used a background worker thread which will be loading the data and when done will notify the application that it has done its work.   Now came a real problem. All the UI (main form and its child usercontrols) was created on the primary main thread. In the LOAD method of the usercontrol I'm fetching data based on the values of some control (like textbox) on userControl.    The pseudocode would look like this:  CODE 1  UserContrl1_LoadDataMethod() {     if (textbox1.text == "MyName") // This gives exception     {         //Load data corresponding to "MyName".         //Populate a globale variable List&lt;string&gt; which will be binded to grid at some later stage.     } }   The Exception it gave was     Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.   To know more about this I did some googling and a suggestion came up like using the following code  CODE 2  UserContrl1_LoadDataMethod() {     if (InvokeRequired) // Line #1     {         this.Invoke(new MethodInvoker(UserContrl1_LoadDataMethod));         return;     }      if (textbox1.text == "MyName") // Now it wont give an exception     {     //Load data correspondin to "MyName"         //Populate a globale variable List&lt;string&gt; which will be binded to grid at some later stage     } }   BUT BUT BUT... it seems I'm back to square one. The Application again  become nonresponsive. It seems to be due to the execution of line #1 if condition. The loading task is again done by the parent thread and not the third that I spawned.  I don't know whether I perceived this right or wrong. I'm new to threading.  How do I resolve this and also what is the effect of execution of Line#1 if block?  The situation is this: I want to load data into a global variable based on the value of a control. I don't want to change the value of a control from the child thread. I'm not going to do it ever from a child thread.   So only accessing the value so that the corresponding data can be fetched from the database.
Calculate the area on a sphere of the intersection of two spherical caps How to set a command block with a command inside using the setblock command I want to emphasize that I only have 5 dollars, so can I use the sentence:     Five dollars is all I have.   Or must it be:      Five dollars are all I have.   Please give the explanation as well. Magento: Merge Product Description and Addition Information Tab I have a MicroSD card in a USB adapter (which plugs into a USB port on my machine, and acts like a USB flash drive). I was using Unetbootin to make this a bootable USB flash drive with Kubuntu. But I needed to cancel while it was working. So I killed the Unetbootin process from the console.  Since then, I can't format the MicroSD or delete the folder that Kubuntu made. I have also tried mkdosfs, with no success. I can't mount the drive anymore either? What can I do to make this drive usable again?  Trying to create a new partition table in GParted, as described in Eliah Kagan's answer, does not work. It fails with the error message "imposible crear tabla de particiones" ("unable to create a partition table"). if there are 4 different tables and 18 people, how many ways can the people be seated to have at least 4 in each table? For example with 15 people at 3 different tables each seating 5 people, is the number of combinations of seating equal to: $$\binom{15}5\binom{10}5(4!)^3$$ Two finite abelian groups with the same number of elements of any order are isomorphic Suppose $G, H$ are finite abelian groups with the same number of elements of any given order. Show they are isomorphic.   Since finite abelian groups are isomorphic if and only if their Sylow subgroups are, we may restrict our attention to the case where $G, H$, are $p$-groups, but I can't quite make it past there... Nouns can modify nouns: cat food, coffee cup, gold ring, laser surgery, flood insurance. It seems to me there are even cases where a noun sounds better than the corresponding adjective: sociology papers sounds a bit better than sociological papers.  Some noun-noun combinations don&rsquo;t work. You wouldn't say America gangsters or measurement spoons or greed crimes. If you spilled water on your keyboard you probably wouldn't call it a keyboard spill or even a water spill.  Are there rules that tell which combinations are acceptable? fitch style proof problem regarding rule of inferences Okay I have the following fitch proof almost figured out, from here I know I have to move forth in conlcuding but I don't know what I am missing  (2 premises)  S → (R ∨ P)  P → (¬R → Q)   my work below  new scope assume S   Rule: > elim  R ∨ P  New scope assume R  Q∨R     Rule: V intro  End scope – (new scope assume P)  ¬R → Q         Rule: > Elim  my confusion comes where I go from here  Q∨R            rule Taut Con ??  Goal:├ S → (Q ∨ R) What does the 'B' (or bonus) mean on a basketball scoreboard? How do I parse an ISO 8601-formatted date? I need to parse  strings like "2008-09-03T20:56:35.450686Z" into Python's datetime type.  I have found  in the Python standard library, but it is not very convenient.  What is the best way to do this? What is the most efficient way to convert a MySQL query to CSV in PHP please?  It would be best to avoid temp files as this reduces portability (dir paths and setting file-system permissions required).  The CSV should also include one top line of field names. Try Ubuntu - Where does it store my files? I am wondering, when you select the option of just "Try Ubuntu" instead of installing, where does Ubuntu store the files that you download / copy / save?  I right click in the Home folder, and it specified I had 4GB free space. Where did it get this 4GB space from, and if I transition to another OS system, how can I access or delete all the previous data from the session of "Try Ubuntu"?  Thank you! Is there a term for the moment when a lot of users visit/log onto your website at the same time? Is there a term for the moment when a lot of users visit/log onto your website at the same time? There are two 9-digit numbers on the back of the Global Entry card. The one on the upper left corner is the Known Traveler Number or PASSID. But on the upper right hand corner there is another 9-digit number, slightly larger than the PASSID. What is the purpose of this second 9-digit number? Mesh imported to Unity is inside out I'm importing a mesh i made into unity before exporting I always rotate it by -90 degrees in the X axis, then set the orientation to Y forward and Z up so when the object is imported to unity the object's orientation will fit into unity's native orientation, However whenever I do this after being importing to Unity the mesh is inside out or transparent but When I don't do the rotation of -90 on the X axis the mesh loads correctly aside from the orientation of the mesh being incorrect and it doesn't match unity's native orientation, i really can't figure it out this is the first time I'm having this problem My setup usually works in the meshes i import to unity but this time i got this problem. Certificate error when using Citrix Receiver How to strike through obliquely, e.g. to indicate cancellation? Many econometrics textbooks (e.g. Wooldridge, "Econometric analysis...") simply write something similar to: "If the population model is $y = xB + u$ and (1) $\text{Cov}(X,U) = 0$; (2) $X'X$ is full rank, then OLS consistently estimate parameters $B$". I've worked out the math behind consistency but I'm a bit lost in interpreting the meaning.  We're talking about consistent estimation, but estimation of what? Please tell me if the following points are correct:   If we have random sample $X,Y$ and $X'X$ is invertible, then we can always define Best Linear Predictor of $y$ given $x$. And then OLS always consistently estimates coefficients of Best Linear Predictor (because in BLP we have $\text{Cov}(u,x)=0$ from the definition). Bottom line: we can always interpret OLS estimates as coefficients of BLP The only question is whether BLP corresponds to conditional expectation $\text{E}(y|x)$. If it does (for which we need $\text{E}(u|x) = 0$), then we can interpret OLS estimates as partial effects.   What is wrong with this or what am I missing? I don't get the point of stating the assumption of $\text{Cov}(u,x) = 0$, if this assumption is by definition fulfilled in case of Best Linear Predictor. And if we want to give structural interpretation to BLP coefficients (partial effects) we need stronger assumption of $\text{E}(u|x) = 0$ anyway. Is there any other interpretation we may have with zero covariance? How does HOTP keep in sync?