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!
23 2191
Im not sure what version your using but,
form.refresh is an option in some versions of vb
example:
me.refresh
Or
textbox1.refresh
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!
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.
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
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)
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]
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()
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!
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
Sorry abt that! I thought I was using Timer in thread - but anyways both should work! Any ideas what I can do?
Plater 7,872
Recognized Expert Expert
Well the forms.timer won't work if you are doing all your work on the same thread.
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!
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. -
// Create the delegate that invokes methods for the timer.
-
TimerCallback mytimerDelegate = new TimerCallback(UpdateStatus);
-
-
// Create a timer that signals the delegate to invoke
-
// UpdateStatus after 1/2 second, and every 1/4 second thereafter.
-
Timer stateTimer = new Timer(timerDelegate, mytimerDelegate, 500, 250);
-
-
public void UpdateStatus(Object stateInfo)
-
{
-
//do stuff in your timer-triggered thread
-
}
-
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?
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.
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. -
// Create the delegate that invokes methods for the timer.
-
TimerCallback mytimerDelegate = new TimerCallback(UpdateStatus);
-
-
// Create a timer that signals the delegate to invoke
-
// UpdateStatus after 1/2 second, and every 1/4 second thereafter.
-
Timer stateTimer = new Timer(timerDelegate, mytimerDelegate, 500, 250);
-
-
public void UpdateStatus(Object stateInfo)
-
{
-
//do stuff in your timer-triggered thread
-
}
-
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
Thanks again Plater for merging the threads. Can you please advise how to resolve this?
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.
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]?
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.
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!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |