Re: Quick Question on Application.Exit()

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Doug Handler" <dkhandler@xxxxxxxxx> wrote in message
news:O9Bzh8Q9FHA.1416@xxxxxxxxxxxxxxxxxxxxxxx
> In C# 2.0, w/ the Program.cs file, i noticed that the Application.Run(new
> appname()) is run twice. I have in my constructor to do a check for a
> settings file, and if it isn't found, the application exits. But the app
> doesn't exit, can someone tell me what i'm doing wrong?
>
> here's my code:
> if (filename == null)
>
> Application.Exit();
>
>
How sure are you that filename is really null? I ask because a quick test
using a String explicitly set to null allows Application.Exit() to be called
and results in the expected termination here.
Have you walked through the code in the debugger to see the value assigned
to filename?
Note also that "" appears not to be equivalent to null. If I assign: String
s = ""; then testing if(s == null) returns false.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.


.



Relevant Pages

  • Re: Quick Question on Application.Exit()
    ... > appname) is run twice. ... I have in my constructor to do a check for a ... > settings file, and if it isn't found, the application exits. ... this code doesn't check for the existance of a file, only that the filename ...
    (microsoft.public.dotnet.languages.csharp)
  • Class ErrorException and inheritance
    ... [, string $filename ... [, long $lineno ... SuperErrorException extends ErrorException, ... the constructor of the subclass should at least contain the same ...
    (alt.php)
  • Class ErrorException and inheritance
    ... [, string $filename ... [, long $lineno ... SuperErrorException extends ErrorException, ... the constructor of the subclass should at least contain the same ...
    (comp.lang.php)
  • java.util.zip.ZipFile doesnt take InputStream as constructor
    ... I'm trying to arbitrarily pull files out of a multi-100-meg zip file. ... constructor the filename. ... constructor that takes anything but a file/filename. ... data isn't a file itself but an inputstream? ...
    (comp.lang.java.programmer)
  • Re: Start application & continue after app exits
    ... and instead of launching Word I'm launching an editor named "gedit". ... This function will be called when the interpreter exits. ... Only one function may be installed in this way; to allow multiple functions which will be called at termination, use the atexit module. ...
    (comp.lang.python)