473,503 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto refresh splash screen

84 New Member
Hi Guys,
I have made an application which has a splash screen. This has one of the delegates to update a string which works fine.

My issue is that I want to automatically refresh this splash every 2 secs. I have tried with Timer & thread but havent been able to implement it properly [I have used threads and timer before but still]. The splash screen is pretty dumb with only to show text while the app works in the back ground. The splash object is created and just splashObj.Visible = true; this allows me to continue with the current process.

Please help!
May 28 '08 #1
23 2191
jamesd0142
469 Contributor
Im not sure what version your using but,

form.refresh is an option in some versions of vb

example:
me.refresh
Or
textbox1.refresh
May 28 '08 #2
alag20
84 New Member
Im not sure what version your using but,

form.refresh is an option in some versions of vb

example:
me.refresh
Or
textbox1.refresh
Sorry I forgot. I am using c# - .Net 2. I know you can do this.Refresh() which works fine in most cases but if I start a timer and on timer tick, if i do this.Refresh() then this doesnt work!
May 28 '08 #3
Plater
7,872 Recognized Expert Expert
you have to make sure you are refreshing the correct object(s). "me" or "this" might not be refering to the correct object in all cases.

And it's .Update() that you should be using to force a redrew of a control. It's available on all controls I believe.
May 28 '08 #4
jamesd0142
469 Contributor
you have to make sure you are refreshing the correct object(s). "me" or "this" might not be refering to the correct object in all cases.

And it's .Update() that you should be using to force a redrew of a control. It's available on all controls I believe.

Is this the case in vb also?
Whats the difference between refresh and update?

James
May 29 '08 #5
Plater
7,872 Recognized Expert Expert
Hmm, now I'm not sure.
Refresh says it invalidates then redraws
Update says it redraws the already invalid region

I think refresh just takes more time because it has to do multiple windows messages (or at least more then update should take)
May 29 '08 #6
alag20
84 New Member
Here is the sample code I use. As you can see I am using Timer and hopefully on every tick it should refresh [I am using refresh coz I need it to invalidate the whole screen and redraw it]

I am calling it as below:
SplashScreen test = new SplashScreen();


and then whenever I need to display it test.Visible = true / false;


I hope this explains my issue!

[HTML]
.......
using Timer = System.Windows.Forms.Timer;

public partial class SplashScreen : Form
{

Timer myTimer = new Timer();

public Splash()
{
InitializeComponent();
}

private void Splash_Load(object sender, EventArgs e)
{
myTimer.Interval = 1000;
myTimer.Tick += new EventHandler(myTimer_Tick);
myTimer.Start();
}

void myTimer_Tick(object sender, EventArgs e)
{
if (this.Visible) this.Refresh();
}}
}[/HTML]
May 29 '08 #7
Plater
7,872 Recognized Expert Expert
Assuming that .Start() is a valid function on timer (never used it) that all looks right.
Once every second the form should update. But you say it's not?

I do something rather similar. I have a form that performs an in-depth search on things. So I popup a little window that says "Searching..." in big letters then below it I give a more detailed message "Searching item 124 / 409876" and it gets incrementend on each change of the number. The numbers move very fast, but they do appear to be updating correctly.

EDIT: I should point out that a timer_tick relies entirely on the sending of a windows message. If that thread is busy, the message will never get through.
If you are doing something in a loop, try throwing in an Application.DoEvents()
May 29 '08 #8
alag20
84 New Member
Well I have something similar in my app. But my only issue is sometimes when there is a big file to copy then this screen seems like hanged / crashed!


I cant even send Application.DoEvents during big file copy as suggested by you but I am also thinking that this could be the issue!

Any other idea's?

Ps : Timer is a thread, and you can start any Thread by thread.Start() - It works on its own!
May 29 '08 #9
Plater
7,872 Recognized Expert Expert
System.Threading.Timer is a thread
System.Windows.Forms.Timer is NOT a thread.

.Start() is available on both, for the Forms.Timer that you are using, it's the same as saying .Enabled=true
May 29 '08 #10
alag20
84 New Member
Sorry abt that! I thought I was using Timer in thread - but anyways both should work! Any ideas what I can do?
May 29 '08 #11
Plater
7,872 Recognized Expert Expert
Well the forms.timer won't work if you are doing all your work on the same thread.
May 29 '08 #12
alag20
84 New Member
Well the forms.timer won't work if you are doing all your work on the same thread.
I am not doing any processing in that - but I have also tried with the thread timer and it didnt seem to work either!
Jun 3 '08 #13
Plater
7,872 Recognized Expert Expert
So you have created a TimerCallback and everything?
Really I don't know why all this work is needed, I've never needed anything so extravagant for it.

Expand|Select|Wrap|Line Numbers
  1. // Create the delegate that invokes methods for the timer.
  2. TimerCallback mytimerDelegate = new TimerCallback(UpdateStatus);
  3.  
  4. // Create a timer that signals the delegate to invoke 
  5. // UpdateStatus after 1/2 second, and every 1/4 second thereafter.
  6. Timer stateTimer = new Timer(timerDelegate, mytimerDelegate, 500, 250);
  7.  
  8. public void UpdateStatus(Object stateInfo)
  9. {
  10.    //do stuff in your timer-triggered thread
  11. }
  12.  
Jun 3 '08 #14
alag20
84 New Member
Hi,
I posted this question a while back and had a bit of help from Plater [thanks] - but it seems to be still not working.


I am attaching the file here


I am looking to call SplashScreen splash = SplashScreen.GetInstance();
then whenever I want to show this i want to call splash.visible = true & splash.visible = false.

It gives me a cross threading exception when I try to myForm.Refresh() or myForm.Update() [even this. has the same error]..... Please help.


Can someone please have a look and advice what lines do i need to modify?
Jun 18 '08 #15
r035198x
13,262 MVP
Post a link to the thread where you previously got help on this for further reference. You should probably have just used that same thread.
Jun 18 '08 #16
alag20
84 New Member
Post a link to the thread where you previously got help on this for further reference. You should probably have just used that same thread.
http://bytes.com/forum/showthread.ph...78#post3168978
Jun 18 '08 #17
alag20
84 New Member
So you have created a TimerCallback and everything?
Really I don't know why all this work is needed, I've never needed anything so extravagant for it.

Expand|Select|Wrap|Line Numbers
  1. // Create the delegate that invokes methods for the timer.
  2. TimerCallback mytimerDelegate = new TimerCallback(UpdateStatus);
  3.  
  4. // Create a timer that signals the delegate to invoke 
  5. // UpdateStatus after 1/2 second, and every 1/4 second thereafter.
  6. Timer stateTimer = new Timer(timerDelegate, mytimerDelegate, 500, 250);
  7.  
  8. public void UpdateStatus(Object stateInfo)
  9. {
  10.    //do stuff in your timer-triggered thread
  11. }
  12.  
Here is my code in the new thread [bytes wasnt letting me post on this thread previously when I made the new thread] http://bytes.com/forum/showthread.ph...41#post3182241
Jun 18 '08 #18
Plater
7,872 Recognized Expert Expert
Here is my code in the new thread [bytes wasnt letting me post on this thread previously when I made the new thread] http://bytes.com/forum/showthread.ph...41#post3182241
*Taken care of*

MODERATOR
Jun 18 '08 #19
alag20
84 New Member
*Taken care of*

MODERATOR

Thanks again Plater for merging the threads. Can you please advise how to resolve this?
Jun 18 '08 #20
Plater
7,872 Recognized Expert Expert
The cross threading exception usually only popups when debuging (it gets ignored in a regular build)
You would want to use the InvokeRequired property on your gui items to find out if you need to invoke (force the command to execute on the same thread) for the gui.
Jun 18 '08 #21
alag20
84 New Member
The cross threading exception usually only popups when debuging (it gets ignored in a regular build)
You would want to use the InvokeRequired property on your gui items to find out if you need to invoke (force the command to execute on the same thread) for the gui.
Sorry but I am a bit lost there... Can you please explain [the Invoke bit]?
Jun 18 '08 #22
Plater
7,872 Recognized Expert Expert
Sorry but I am a bit lost there... Can you please explain [the Invoke bit]?
Just follow the messages it gives you when you get the exception. MSDN has a few examples that work well to solve that problem.
Jun 18 '08 #23
alag20
84 New Member
Just follow the messages it gives you when you get the exception. MSDN has a few examples that work well to solve that problem.
Works like a charm when released and used outside VS.



Thanks a ton - You guys rock!
Jun 18 '08 #24

Sign in to post your reply or Sign up for a free account.

Similar topics

2
6908
by: Bill | last post by:
Problem 1) Any ideas on how I would get a splash screen to appear for a certain amount of time when I open a database - it's to display a text based disclaimer message. I know about message...
3
2250
by: andrewcw | last post by:
I implemented the simplest of splash screens ( static and on its own thread ). But it seem that when first called maybe 8 seconds elapsed before it showed up, the main form follows several seconds...
14
6677
by: SStory | last post by:
I am trying to make a splash screen for my vb.net app. It is an mdi app. including the splash code produces wierd results. not inluding makes things fine. Also have tried loading the splash...
2
2098
by: Joe Cool | last post by:
Using VB in VS2005. 2005 has a new way to implment a spash screen that alleviates the need for hardly any code. But I have found that when a GUI that has a splash screen is run as a scheduled task,...
1
2237
by: Ken Allen | last post by:
I am developing a small utility program that must perform a considerable amount of 'background' or 'research' work before it can display any user interface. In general it can take 3-15 seconds to...
5
6385
by: steve | last post by:
Hi All I have a form set as the splash screen in VB.net 2005 application properties How can I tell when it has or is closing, as I want to then run some licence checking code without the...
2
4192
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...
10
22305
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...
4
5193
by: Gaz | last post by:
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...
0
7205
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,...
0
7093
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...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5023
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...
0
4689
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...
0
3180
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...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.