Hi, I am working with winform and trying to use MessageBox to handle exceptions. The strange thing is, MessageBox appears only after closing the main form ("Form1" in the code below).
public class Worker { } public class Form1 { void button_Click(object sender, EventArgs e) {
What could be the best way to use MessageBox to handle exceptions?
... So I added some codes for MessageBox-ing to the user interface stream, but the problem remains.
public class WorkExceptionArgs : EventArgs { public Exception e; public WorkExceptionArgs (Exception e) { this.e = e; } } public partial class Worker1 {
Actually there was a different form and a different worker. When Worker (Worker1) has established a connection to the server, Form1 hides (.Hide ()), Form2 shows (.Show ()), and Worker2 starts working with the created Work.conf connection.
public class Worker2 { Worker2(Worker1 w1, Form2 frm2) { this.w1=w1; this.frm2=frm2; } public Worker1 w1; public Form2 frm2; public event EventHandler<WorkExceptionArgs> workException; public void doSomeOtherWork() {
source share