Pocket PC Windows App

Hello,

I have a question related to the execution of CF .NET Win App code.

private void Form1_Load(object sender, System.EventArgs e)
{
label1.Text = "Waiting for connection...";

Connect(); // uninportant implementation

label1.Text = "Done.";

}

Connect() function is running in circle, until it doesn't get a connection. This could be from 5 seconds, till 5 hours. The problem(?) is, that until the function Connect() is running, my PDA is showing me the "loading circle".

How could I refresh the window, so that there would be a msg "Waiting for connection...", before the function Connect() would start.

Thanks in advance.

[694 byte] By [IgorP] at [2007-12-22]
# 1

HI,

Try the below code:

private void Form1_Load(object sender, System.EventArgs e)
{
label1.Text = "Waiting for connection...";
label1.Update(); // Added extra line
Connect(); // uninportant implementation

label1.Text = "Done.";
label1.Update(); // Added extra line
}

Regards,

Prashant

prashantmulay at 2007-8-30 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 2
Ok. When I add the line label1.Update() after label1.Text = "Waiting for connection..."; line, the situation changes.

The "loading circle" freezes and there is a label in the middle of the screen, where text Waiting for connection is placed. The problem is, Form background is completly transparent (I am seeing windows desktop).

To conclude, only the label is shown (refreshed), not the whole form. I think something like c++ (MFC) draw function, would solve the problem, and refresh the whole form.

IgorP at 2007-8-30 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 3
The answer is this.Refresh() inside the Form_Load function.

Thanks for the Update() idea.

IgorP at 2007-8-30 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 4
So where did you place the this.Refresh() call in your code?

(You could always put that Connect() logic onto a thread, and get that to talk to back to the UI)

Tryst at 2007-8-30 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 5
I placed this.Refresh() at the start of the 'OnLoad' function.

About placing my code into a seperated thread. How is it possible to change some labels on the Form, while the thread is running?

I didn't mange to find this out.

IgorP at 2007-8-30 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...