i Have made a program in c# which show 2 types of form 1 is getting values from the user and save it in Database and second is showing those values in a template of crystal report.
My problem is when i move 1st form to 2nd form i hide the first form by using hide(); function and after getting the value on 2nd form from Database i move back to 1st form and hide the second form and show 1st but when i close the whole program it keep running and debugger showing its and running and also have a process in task manager.
I want to know how can i close that background process with the form1 close. sorry for my bad English.
rollno = txtrollno.Text;
ReportCard objreport = new ReportCard();
objreport.Show();
this.Hide();
this is the code for hiding the 1st form .
Form1 objshow = new Form1();
objshow.Show();
this.Hide();
and in this i hide 2nd and show 1st again.
Try using
When a form is closed, all resources created within the object are closed and the form is disposed. You can prevent the closing of a form at run time by handling the Closing event and setting the Cancel property of the CancelEventArgs passed as a parameter to your event handler. If the form you are closing is the startup form of your application, your application ends.
or
This method stops all running message loops on all threads and closes all windows of the application. This method does not force the application to exit. The Exit method is typically called from within a message loop, and forces Run to return. To exit a message loop for the current thread only, call ExitThread .
or
Terminates this process and gives the underlying operating system the specified exit code. This call requires that you have SecurityPermissionFlag.UnmanagedCode permissions. If you do not, a SecurityException error occurs. This is the call to use if you are running a console application.