473,748 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating New Threads to Show a Splash and Login Screen

Gaz
I am having a bit of a problem getting my application to work
properly.

RIght here is my problem...

WHen my C# windows app loads up the start form, i create a new thread
and show the splash on the new thread and put the main thread to sleep
until the splash screen has done the business, then i kill the new
thread and start another to show the login and again put the main one
to sleep. Problem i have is that my splash screen will show ie has
focus but when my login box appears it is minimised to the taskbar??
and doesnt show up on the screeen like i want it to.

Here is my Code:

//Load the Splash Screen
private void DoSplash()
{
Splash sp = new Splash();
DialogResult Res;

Res = sp.ShowDialog() ;
if (Res == DialogResult.Ab ort)
{
KillApp = true;
}

WakeThread = true;

}

//Here is my Login Form
private void ShowLogin()
{
Login lg = new Login();
DialogResult Res;

Res = lg.ShowDialog() ;
if (Res != DialogResult.OK )
{
KillApp = true;
}

WakeThread = true;

}

and finally my initial form constructor

//Show Splash Screen
Thread th = new Thread(new ThreadStart(DoS plash));
th.Start();
while (WakeThread == false)
{ Thread.Sleep(10 00); }

th.Abort();

if (KillApp)
{ KillApplication (); }
//end of splash screen
//Show Login Box
WakeThread = false;
Thread thLogin = new Thread(new ThreadStart(Sho wLogin));
thLogin.Start() ;
while (WakeThread == false)
{ Thread.Sleep(10 00); }

thLogin.Abort() ;

if (KillApp)
{ KillApplication (); }
//end of Login

//GOOD TO GO.....
InitializeCompo nent();
Can anyone offer a suggestion to what i am doing wrong or if someone
has a better way of doing what im trying to then please let me know :)

Thanks
Jun 27 '08 #1
4 5221
Gaz,
WHen my C# windows app loads up the start form, i create a new thread
and show the splash on the new thread and put the main thread to sleep
until the splash screen has done the business

What is the senze of your solution, this you can do with a simple.

\\\
Form splasy = new Form();
//Set what you want on splasy
splasy.ShowDial og();
splazy.Dispose( );
///

The effect is the same.

The meaning of multithreading with a splash screen is to do initialization
operations while the splash screen is showed, not to stop it.

Cor
"Gaz" <go********@gma il.comschreef in bericht
news:d5******** *************** ***********@a70 g2000hsh.google groups.com...
>I am having a bit of a problem getting my application to work
properly.

RIght here is my problem...

WHen my C# windows app loads up the start form, i create a new thread
and show the splash on the new thread and put the main thread to sleep
until the splash screen has done the business, then i kill the new
thread and start another to show the login and again put the main one
to sleep. Problem i have is that my splash screen will show ie has
focus but when my login box appears it is minimised to the taskbar??
and doesnt show up on the screeen like i want it to.

Here is my Code:

//Load the Splash Screen
private void DoSplash()
{
Splash sp = new Splash();
DialogResult Res;

Res = sp.ShowDialog() ;
if (Res == DialogResult.Ab ort)
{
KillApp = true;
}

WakeThread = true;

}

//Here is my Login Form
private void ShowLogin()
{
Login lg = new Login();
DialogResult Res;

Res = lg.ShowDialog() ;
if (Res != DialogResult.OK )
{
KillApp = true;
}

WakeThread = true;

}

and finally my initial form constructor

//Show Splash Screen
Thread th = new Thread(new ThreadStart(DoS plash));
th.Start();
while (WakeThread == false)
{ Thread.Sleep(10 00); }

th.Abort();

if (KillApp)
{ KillApplication (); }
//end of splash screen
//Show Login Box
WakeThread = false;
Thread thLogin = new Thread(new ThreadStart(Sho wLogin));
thLogin.Start() ;
while (WakeThread == false)
{ Thread.Sleep(10 00); }

thLogin.Abort() ;

if (KillApp)
{ KillApplication (); }
//end of Login

//GOOD TO GO.....
InitializeCompo nent();
Can anyone offer a suggestion to what i am doing wrong or if someone
has a better way of doing what im trying to then please let me know :)

Thanks
Jun 27 '08 #2
Can anyone offer a suggestion to what i am doing wrong or if someone
has a better way of doing what im trying to then please let me know :)
Check the archives for "Ignacio machin" "splash screen"
I have posted code for doing this exactly.
Jun 27 '08 #3
On May 12, 4:44 am, Gaz <gonkowo...@gma il.comwrote:
I am having a bit of a problem getting my application to work
properly.

RIght here is my problem...

WHen my C# windows app loads up the start form, i create a new thread
and show thesplashon the new thread and put the main thread to sleep
until thesplashscreen has done the business, then i kill the new
thread and start another to show the login and again put the main one
to sleep. Problem i have is that mysplashscreen will show ie has
focus but when my login box appears it is minimised to the taskbar??
and doesnt show up on the screeen like i want it to.

Here is my Code:

//Load theSplashScreen
private void DoSplash()
{
Splashsp = newSplash();
DialogResult Res;

Res = sp.ShowDialog() ;
if (Res == DialogResult.Ab ort)
{
KillApp = true;
}

WakeThread = true;

}

//Here is my Login Form
private void ShowLogin()
{
Login lg = new Login();
DialogResult Res;

Res = lg.ShowDialog() ;
if (Res != DialogResult.OK )
{
KillApp = true;
}

WakeThread = true;

}

and finally my initial form constructor

//ShowSplashScree n
Thread th = new Thread(new ThreadStart(DoS plash));
th.Start();
while (WakeThread == false)
{ Thread.Sleep(10 00); }

th.Abort();

if (KillApp)
{ KillApplication (); }
//end ofsplashscreen

//Show Login Box
WakeThread = false;
Thread thLogin = new Thread(new ThreadStart(Sho wLogin));
thLogin.Start() ;
while (WakeThread == false)
{ Thread.Sleep(10 00); }

thLogin.Abort() ;

if (KillApp)
{ KillApplication (); }
//end of Login

//GOOD TO GO.....
InitializeCompo nent();

Can anyone offer a suggestion to what i am doing wrong or if someone
has a better way of doing what im trying to then please let me know :)

Thanks
This is what i have done..
// I do the login first and then load if necessary

{
splashForm = new SplashForm();
SplashForm.Chec kForIllegalCros sThreadCalls = false;

BackgroundWorke r worker = new BackgroundWorke r();
worker.DoWork += new
DoWorkEventHand ler(worker_DoWo rk);

worker.RunWorke rAsync();

////////////

//Do Work Here

////////////////

splashForm.Clos e();

}

void worker_DoWork(o bject sender, DoWorkEventArgs e)
{
splashForm.Show Dialog();
}
Jun 27 '08 #4
Hi,
* * * * void worker_DoWork(o bject sender, DoWorkEventArgs e)
* * * * {
* * * * * * splashForm.Show Dialog();
* * * * }- Hide quoted text -
You are actually doing the work in the first thread, and just showing
the splashForm in the worker thread.
Wouldn't it make sense to do it the other way around?

You could show the splash screen, do the work in the worker thread,
wait for the work to end and then
define a RunWorkerComple tedEventHandler to close the splash screen.

This will require a cross-thread operation I think, but you can
achieve this by
following this method:

http://msdn.microsoft.com/en-us/libr...28(VS.80).aspx

Joachim

Jun 27 '08 #5

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

Similar topics

1
3620
by: Prabhat | last post by:
Hi all, I am new in VB.NET. I am trying to develop a MDI based Application with Menu, Statusbar, Logon Dialog and Splash Screen. How Do I start with? As in VB 6.0 I used to Write the Code in MAIN Module to display the splash screen and login dialog and after login I used to open the MDI Parent window with all the menu ites set as per the Logged on user rights.
11
997
by: Geoff Jones | last post by:
Hi Can anybody help me with the following? I have a main application, called for the sake of argument Form1, which is going to be the main source of my application code. I've been trying to develop a splash screen to appear before the main application appears i.e. Form1. This splash screen I am going to call Form2. So, what I'm trying to do is start the application, display Form2 and then
4
2510
by: John | last post by:
Hi I have a main sub as start-up. I need to display a splash screen and while it is displayed I need to do some stuff in the background like opening db connections etc. After that is done I need to close splash and open a login form. Can anyone give me a code example of how to do this elegantly? Thanks Regards
2
1384
by: XDJ | last post by:
I could really use some help here... I am using C# 2005 and have created a splash screen that runs on a seperate thread. I can invoke the splash screen in the Main() method, but then I can't get rid of it! I am attempting to put a line in the Form1_Load (or maybe Form1_Shown) that calls a static method from the splash screen to close that form. But, when I do so, it complains about an invalid cross-thread operation. How can I get...
3
7653
by: steve | last post by:
Hi All I have set a splash screen form as the application splash screen in VB.net 2005 I t runs fine but stays on top when my login screen appears How can I shut the splash screen down when the login screen is shown Attempts to close it from the application main form results in error message
0
1210
by: Steve | last post by:
Hi All I have an odd thing happening with my splash screen form The splash screen is set in Project properties and in the 'new' event of the splash form I run some code (before the initialisation) to launch a form asking the user to select which SQL Server 2005 databases to connect to. All worked well I recently added a timer control to check for application inactivity and to
2
4219
by: will_456 | last post by:
In vb2005 Express: In My Project Application Splash Screen I have selected my splash screen form. The form opens on project startup but closes immediately before anyone would have time to read it. I presume it only stays visible while the main form initialises. This is not long enough but I can't see how to slow it down. Should I set the splash screen using the Application settings or go back to
10
22376
by: =?Utf-8?B?UmljaGFyZCBCeXNvdXRo?= | last post by:
Hi In my app I have a SplashScreen, a login form and a main form. On launching the app, I'd like to show the SplashScreen while reading config files and attempting a database connection. I show progress of these tasks on a label on the SplashScreen form. Once this is completed ok, the splash screen should close and the login form should be displayed. A successful login closes that form and shows the main form.
1
4389
by: bassemG | last post by:
Hi evere body I did an application in vb 2005. The application includes 4 databases. I have assigned ten seconds for the splash screen to show while the application is loading. I need to include a progress bar on the`splash screen to show the load progress of the application. Any help is much appreciated
0
8991
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
9552
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9376
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
9249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8245
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
6796
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
4607
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
4877
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2787
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.