Socarsky
Well-known member
- Joined
- Mar 3, 2014
- Messages
- 59
- Programming Experience
- Beginner
I face with that issue, I checked some links on the Internet but failure to find an viable.
My issue comes out when I close second form's FormClosed event I think a delegate causes this matter. First is a login form when login passes correctly then I make the first form hide and second forms come alone on the screen. That delegate for a stopwatch that I show elapsed time on the statusbar.
Note: this line causes problem : this.Inviko(db);
and : The update method called mainForm (second) one.
I call MainForm from loginPass form below:
My issue comes out when I close second form's FormClosed event I think a delegate causes this matter. First is a login form when login passes correctly then I make the first form hide and second forms come alone on the screen. That delegate for a stopwatch that I show elapsed time on the statusbar.
Note: this line causes problem : this.Inviko(db);
and : The update method called mainForm (second) one.
I call MainForm from loginPass form below:
C#:
this.Hide();
MainForm mainform = new MainForm();
mainform.strUser = txtUsername.Text;
mainform.ShowDialog();
namespace QCTX { public partial class MainForm : DevComponents.DotNetBar.Office2007Form { // global variable string timeelepse = string.Empty; public string strUser; public MainForm() { InitializeComponent(); // in button click handler System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); System.Threading.Thread t = new System.Threading.Thread(delegate() { while (true) { TimeSpan ts = sw.Elapsed; string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds); timeelepse = elapsedTime; UpdateLabel(); } }); t.Start(); } public delegate void doupdate(); public void UpdateLabel() { doupdate db = new doupdate(DoUpdateLabel); if (!this.IsDisposed) { this.Invoke(db); } } public void DoUpdateLabel() { labelItem2.Text = timeelepse; } private void MainForm_Load(object sender, EventArgs e) { DateTime dtime = DateTime.Today; dateTimeInput1.Value = dtime; DateTime zaman = DateTime.Now; labelItem1.Text = "User name: (" + strUser + ") --> Logon time: (" + zaman + ") --> Duration: (" + labelItem2.Text + ")"; } } }