title: C# Controling a Form using another thread, also prevent from duplicating forms
body: <p>first of all, i am sorry that even if there's many given topic that may be related to my problem still i cant figure out how to solve my problem..</p>
  
  <p>its just that most of the words used in the coding is new to me.
  i really need your guidance guys.. =(</p>
  
  <p>on to my problem..</p>
  
  <p>i have 2 forms im my project.
  the form1 is acting as my Login Screen
  and form2 is will open if the users login is correct</p>
  
  <p>im using UDP as my connection socket. i made a simple UDPlistener
  inside a Timer(<em>reason is because if i dont close it if theres nothing to read,it will just
  make my program hangs, and still keep on waiting for messages</em>)</p>
  
  <p>Note: my UDP listener is being run on a different thread like this</p>
  
  <pre><code>Thread thread1 = new Thread(UDPListener.StartListener);
  thread1.SetApartmentState(ApartmentState.STA);
  Thread.Sleep(100);
  thread1.TrySetApartmentState(ApartmentState.STA);
  
  thread1.Start();
  </code></pre>
  
  <p>when the Server Program sends me a signal to Open up form2
  the problem now occur..</p>
  
  <p>the problem is.. form2 showed up.. but form1 didn't hide or visible=false; (<em>form1 need to be able to do that</em>) </p>
  
  <p>im doing this code when im trying to show form2 and hide form1
  Note: also another problem is (not really sure) .. i notice its just duplicating the forms</p>
  
  <pre><code>Form1 f1 = new Form1();
  Form2 f2 = new Form2();
  f1.Command("009");
  f1.MiniTicker.Enabled = false; //need to do this, cant do this without putting Form1 f1 = new Form1();
  Login.TBOption.showTaskBar();
  TaskbarHide.Taskbar.Hide();
  f1.CoreAds.Enabled = false; //same here
  
  f1.Visible = false;
  f1.Hide();
  
  f1.Invoke(
  (MethodInvoker)(() =&gt;
  {
  new TimerMode().Show();
  }));
  
  
  f1.Invoke(
  (MethodInvoker)(() =&gt;
  {
  new MainForm().Hide();
  }));
  </code></pre>
  
  <p>Final Note: after i run the code above.. the Form1 is like closing, but after that it open up again... </p>
  
  <p>please help me solve my problem. i need to finish my thesis project =(</p>