…Or at least a class I didn’t know existed, but let’s see if I’m right or not. The
class resides in the System.Web.UI
namespace and is used various places in ASP.NET. Among those places are the inner
workings of the ViewState. The reason you (might) don’t know the class could be because
of its not so strongly typed nature. In other words, if you want to use the class
you have to do a lot of boxing and casting.
As you haven’t already guessed, I’m talking about the Triplet class.
I’ve thought about how to use the class instead of creating my own type-safe little
structures, and I came up with nothing. I don’t know what to do with the class.
Here is how you could use it
Triplet triplet
= new Triplet();
triplet.First
= "string";
triplet.Second
= 34;
triplet.Third
= DateTime.Now;
If you have any good ideas to how you would use this class, please let me know. My
own imagination is limited when it comes to the Triplet class.
>
Whenever a Windows Form is closed, you can catch this event by overriding the OnClosing()
method. In this method you have the option to do some cleanup before it closes. You
can also prevent the Form from closing by cancelling the closing event. That means
that you can turn off the ability to exit a Windows Forms application very easily
and for some applications that’s just what you want. You probable just want to hide
it and let it run in the background.
The only problem is that if the application cannot be closed, then you cannot turn
of Windows because it keeps trying to close the enclosable application. That was a
problem for the Site
Monitor application, so I started reading the MSDN documentation for a way to
fix this issue.
What I found was a new method called OnFormClosing() that
is new to the .NET Framework 2.0. I also found that OnClosing() has
been deprecated but the Intellisense in Visual Studio didn’t show that. The OnFormClosing()
tells you whether it was the user who closed it or if Windows are shutting down or
some other reason.
protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason
== CloseReason.UserClosing)
{
e.Cancel
= true;
DoSomething();
}
}
>
So remember to catch the right event and make sure Windows is able to shut down properly.