473,654 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application.Exi tThread hides a form not associated with its message pump

Hi there movers & shakers,

The example below demonstrates a behaviour that is anoying the tits off of
me! It doesn't happen whilst debugging from the IDE only when you run the
compiled exe from windows explorer. I'm basically trying to display a splash
screen in a seperate thread which has it's own message pump. When the call
to Application.Exi tThread() closes down the splash screen's thread, form and
message pump, the main form (and it's associated message pump) decides that
it has to process a WM_CLOSE message but i can't figure out who, what where
is firing that message. The result of this is that the main form has its
visible property set to false when the splash screen closes. I thought that
the use of the Application.Run () overload that doesn't take a Form as a
parameter wouldn't attach an event handler to the Form.Closed event like it
does in the other overload which is what i thought would be the thing w

Please note: I've seen lots of ways to implement splash screens on the news
groups etc and the examples i've seen are all pretty wanky if you ask me,
I'm not interested in how you have implemented your splash screen, i'm only
interested in explaining the behaviour that i'm seeing as it not only
relates to a splash screen but to other forms we display in our application.
the code below is the simplest i could come up with that demonstrates the
problem

cheers,
burger flavoured snack

using System;
using System.Threadin g;
using System.Windows. Forms;
namespace SplashTest
{
class SplashScreenVie wer
{
Form splashForm;

public void Show()
{
Thread splashThread = new Thread(delegate ()
{
splashForm = new Form();
splashForm.Text = "Splash Form";
splashForm.TopM ost = true;
splashForm.Show ();
Application.Run ();
});

Thread sleepThread = new Thread(delegate ()
{
Thread.Sleep(30 00);
if (splashForm.Inv okeRequired)
splashForm.Begi nInvoke(new MethodInvoker(d elegate() {
Application.Exi tThread(); }));
else
Application.Exi tThread();
});

splashThread.St art();
sleepThread.Sta rt();
}
}

static class Program
{
[STAThread]
static void Main()
{
Application.Ena bleVisualStyles ();

SplashScreenVie wer viewer = new SplashScreenVie wer();
viewer.Show();

Form mainForm = new Form();
mainForm.Text = "Main Form";

Application.Run (mainForm);
}
}
}
Nov 17 '05 #1
0 2436

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2123
by: cube | last post by:
In thread i've got something like this Application.Run(new Form()); But programm shows Form and waits for events. Is there any solution to back from Form()? whithout Application.Exit or Application.ExitThread ? cube
3
1564
by: Matthias Jentsch | last post by:
Hello, I have a simple testapplication: public class Test : ApplicationContext { private static void Main () { Application.Run(new Test()); }
1
17686
by: Brendan Miller | last post by:
I am trying to close my application using Application.exit() in the frmMain_Closing event. When the form closes the process does not. My application only has one form (no other classes either). The form has a really long loop which generates approx. 700 .csv files. I do not create any threads myself (Application.exitthread() doesn't work either). To counteract this I have decided to use the Environment.exit(-1) method instead. What...
4
11153
by: Chuck | last post by:
Hello everybody, I need to abort execution during start up, while the constructor called by Application.Run is executing. If the database fails to connect during my application's startup I want to display a message (no problem here) and then abort the program. However, after the attached code executes I end up with my main form and a wait cursor! If I click on the X the form closes. Boss doesn't think an unhandled exception will...
23
2469
by: jm | last post by:
This works, but I don't know why. static void Main() { // Queue the task. ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProc),new Form1()); Application.Run(); }
6
20066
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are quite a few words in this post but the questions are actually quite similar and should be fairly quick to answer ... (1) What is Happening with the Threads
4
10852
by: Bob Day | last post by:
Using VS 2003, VB.net... I am confused about the Application.Exit method, where the help states "This method does not force the application to exit." Aside from the naming confusion, how do I force the application to exit? See **** below for my comments/questions in a simple example. ****In Sub Main, the Application.Exit works as expected, other sub main code is ignored, and when the end sub is reached the application shuts down....
0
4194
by: Ralf Gedrat | last post by:
Hello! I have a Application, this throws after some time following exception: Item has already been added. Key in dictionary: "- 1" key being added: "- 1" I use Application.Run with ApplicationContext. This error message comes from deeper levels must be thrown (mscorlib.dll?!) ?.
12
2661
by: Pete Smith | last post by:
Which is the appropriate one to use in the above choice? VB.Net. .Net Framework 1.1 Thank you, Pete
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.