Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sat Nov 18, 2017 5:21 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Application Start/Exit
PostPosted: Thu May 26, 2011 9:50 am 
Offline

Joined: Wed May 25, 2011 10:49 am
Posts: 8
Is there a way in iX to access a method that runs on startup and shutdown. I have a C# component I want to run in the background of the application and to terminate on shutdown.


Top
 Profile  
 
PostPosted: Thu May 26, 2011 10:20 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
I typically will use the "Opened" action/event of the startup screen to put my initialization code/actions in a workspace, but your could also use a "static constructor". A static constructor is a part of the C# language. It will execute when a class is included the first time and only once. Here's what one looks like:

Code:
 public partial class ScriptModule1
{
      static ScriptModule1() {
         
      }
}


To shut down an iX terminal, you disconnect power. At this point, there is no power and no way to execute code. Are you developing targeting a unit or PC that has Windows XP? In this case, you might use the action called "Close Application". So if you want to use the "Close Application" action have something happen before this. Put the "Close Application" action on the button release (MouseUp), put all your other code/actions on the button press (MouseDown).

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
PostPosted: Fri May 27, 2011 7:26 am 
Offline

Joined: Wed May 25, 2011 10:49 am
Posts: 8
So you are saying to have a button that the user uses to close the application? My main issue is that when running it on a PC and the user closes the application using the X on the window that the application stays running as the background task never terminated.


Top
 Profile  
 
PostPosted: Tue May 31, 2011 3:31 pm 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
MSDN has documented an application exit event that may help. It is fired when you click the [x] button.
http://msdn.microsoft.com/en-us/library ... .exit.aspx

Code:
public partial class ScriptModule1
{
    public void StartChecking()
    {
        System.Windows.Application.Current.Exit += AppClosed;
    }

    private void AppClosed(System.Object sender, System.Windows.ExitEventArgs e)
    {
        MessageBox.Show("Closing");
    }
}

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group