C# Halting Windows Shutdown to run method

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ewokspy
    New Member
    • Sep 2007
    • 30

    C# Halting Windows Shutdown to run method

    I have a C# windows application that runs with a form hidden and a system tray icon. Now I have read about WndProc and overriding that function to capture windows messages, but When I override it with this:

    Code:
    		protected override void WndProc(ref Message m)
    		{
    			
    			// WM_QUERYENDSESSION
    			if (m.Msg == 0x0011)
    			{
    				this.parentThreader.EndOfDayCheckout();
    			}//end if
    
    			base.WndProc(ref m);
    
    		}//WndProc
    the EndOfDayCheckou t() doesn't ever run. Now is there some special call or thread I need to set up to get EndProc to retrieve messages, or is there something else I need to get the system to halt shutdown until the method I call has finished?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Does your program close down too fast?
    You might have have it spawn something to run that when it closes?

    Comment

    • ewokspy
      New Member
      • Sep 2007
      • 30

      #3
      Originally posted by Plater
      Does your program close down too fast?
      You might have have it spawn something to run that when it closes?
      Yes the program does seem to close down quite fast. The EndoFDayCheckou t is this:

      Code:
      		/// <summary>
      		/// ************************************************************
      		/// Name: EndOfDayCheckout
      		/// 
      		/// Description: This method sets the EndofDay flag to stop further
      		///		DB inquiries, then gets the full list of print jobs from
      		///		today, and populates them into the EndofDay form. Then
      		///		displays the form.
      		///	
      		///	Input Parameters: None
      		///	Output Parameters: None
      		///	Returns: None
      		///	Restrictions: None
      		///	************************************************************ 
      		/// </summary>
      		public void EndOfDayCheckout()
      		{
      			//Ensure no further DB Calls are made by DB thread
      			this.EndOfDay = true;
      
      			//Do a final pull of the DB
      			//Connect to Database
      			PrintAlertDB = new DBConnect(this.Path);
      
      			//Query DB for this user
      			PrintAlertDB.LoadSQLTableReader(GetWindowsUserID());
      
      			//Populate the Dataset
      			frmEOD.PopulateGridWithJobs(PrintAlertDB.SQLTable);
      
      			//Show the End of Day Form
      			frmEOD.ShowDialog();
      			frmEOD.Refresh();
      
      		}//EndOfDayCheckout
      So it supposed to perform a DB query, populate the data grid and display the form. Everything just shuts down though.

      So what kind of spawn do I need to do?

      Comment

      Working...