Hi,

Under a Windows CE .NET 4.2 OS, I have a problem with a C# application which
is the following :
when I call often a routine, my application is blocked on the MessageBox and
I must do a reboot of the PDA.

The routine is the following :

---------------------------------------------------------------------
private void routine()
{
MessageBox.Show("Message", "Title");
textBox1.Text = "";
textBox1.Enabled = false;
textBox2.Enabled = true;
textBox2.Text = "";
textBox2.Focus();
}
-------------------------------------------------------
When I debug, I have no message, I can see where the program is blocking.
I think it's a problem between the MessageBox and the focus on "textBox2"
field ?

Thanks for any help.

Re: C# application is blocked by Ginny

Ginny
Tue Mar 28 06:32:21 CST 2006

If you comment out the textBox2.Focus() do you have the same problem?

--
Ginny Caughey
.NET Compact Framework MVP


"Gandalf" <Gandalf@discussions.microsoft.com> wrote in message
news:44259113-26A5-40A8-8051-2559258F9AA1@microsoft.com...
> Hi,
>
> Under a Windows CE .NET 4.2 OS, I have a problem with a C# application
> which
> is the following :
> when I call often a routine, my application is blocked on the MessageBox
> and
> I must do a reboot of the PDA.
>
> The routine is the following :
>
> ---------------------------------------------------------------------
> private void routine()
> {
> MessageBox.Show("Message", "Title");
> textBox1.Text = "";
> textBox1.Enabled = false;
> textBox2.Enabled = true;
> textBox2.Text = "";
> textBox2.Focus();
> }
> -------------------------------------------------------
> When I debug, I have no message, I can see where the program is blocking.
> I think it's a problem between the MessageBox and the focus on "textBox2"
> field ?
>
> Thanks for any help.
>



Re: C# application is blocked by Chris

Chris
Tue Mar 28 08:51:28 CST 2006

Is "routine" running in a separate thread or in an event handler (like for a
timer)?

-Chris


"Gandalf" <Gandalf@discussions.microsoft.com> wrote in message
news:44259113-26A5-40A8-8051-2559258F9AA1@microsoft.com...
> Hi,
>
> Under a Windows CE .NET 4.2 OS, I have a problem with a C# application
> which
> is the following :
> when I call often a routine, my application is blocked on the MessageBox
> and
> I must do a reboot of the PDA.
>
> The routine is the following :
>
> ---------------------------------------------------------------------
> private void routine()
> {
> MessageBox.Show("Message", "Title");
> textBox1.Text = "";
> textBox1.Enabled = false;
> textBox2.Enabled = true;
> textBox2.Text = "";
> textBox2.Focus();
> }
> -------------------------------------------------------
> When I debug, I have no message, I can see where the program is blocking.
> I think it's a problem between the MessageBox and the focus on "textBox2"
> field ?
>
> Thanks for any help.
>



Re: C# application is blocked by Daniel

Daniel
Fri Mar 31 19:11:53 CST 2006

Like Chris is implying, chances are you are running that method on a worker
thread and hence should use Control.Invoke before touching UI elements:
http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html

Cheers
Daniel
--
http://www.danielmoth.com/Blog/

"Gandalf" <Gandalf@discussions.microsoft.com> wrote in message
news:44259113-26A5-40A8-8051-2559258F9AA1@microsoft.com...
> Hi,
>
> Under a Windows CE .NET 4.2 OS, I have a problem with a C# application
> which
> is the following :
> when I call often a routine, my application is blocked on the MessageBox
> and
> I must do a reboot of the PDA.
>
> The routine is the following :
>
> ---------------------------------------------------------------------
> private void routine()
> {
> MessageBox.Show("Message", "Title");
> textBox1.Text = "";
> textBox1.Enabled = false;
> textBox2.Enabled = true;
> textBox2.Text = "";
> textBox2.Focus();
> }
> -------------------------------------------------------
> When I debug, I have no message, I can see where the program is blocking.
> I think it's a problem between the MessageBox and the focus on "textBox2"
> field ?
>
> Thanks for any help.
>





Re: C# application is blocked by Gandalf

Gandalf
Wed Apr 05 05:27:01 CDT 2006

OK, thanks.
But what do you mean exactly, should I use this method after
"MessageBox.Show()" ? So "textBox2.Invoke()" in the sample of code I gave you
in the last post ?

Thanks in advance for any information.

"Daniel Moth" wrote:

> Like Chris is implying, chances are you are running that method on a worker
> thread and hence should use Control.Invoke before touching UI elements:
> http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
> "Gandalf" <Gandalf@discussions.microsoft.com> wrote in message
> news:44259113-26A5-40A8-8051-2559258F9AA1@microsoft.com...
> > Hi,
> >
> > Under a Windows CE .NET 4.2 OS, I have a problem with a C# application
> > which
> > is the following :
> > when I call often a routine, my application is blocked on the MessageBox
> > and
> > I must do a reboot of the PDA.
> >
> > The routine is the following :
> >
> > ---------------------------------------------------------------------
> > private void routine()
> > {
> > MessageBox.Show("Message", "Title");
> > textBox1.Text = "";
> > textBox1.Enabled = false;
> > textBox2.Enabled = true;
> > textBox2.Text = "";
> > textBox2.Focus();
> > }
> > -------------------------------------------------------
> > When I debug, I have no message, I can see where the program is blocking.
> > I think it's a problem between the MessageBox and the focus on "textBox2"
> > field ?
> >
> > Thanks for any help.
> >
>
>
>
>
>

Re: C# application is blocked by Daniel

Daniel
Wed Apr 05 05:48:19 CDT 2006

If you read the link I sent and the links it points to you will get the
answer to the question you ask, gain a better understanding on why the
advice was given and also never face this problem again.

Whether you decide to Invoke from wherever you call that routine so the
whole method is on the UI thread or whether you decide to split the method
so the msgbox happens before Invoking is your decision which you will be
able to make once you follow the links.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/

"Gandalf" <Gandalf@discussions.microsoft.com> wrote in message
news:56EA23C0-DF46-426D-80B0-9D750D32DEB9@microsoft.com...
> OK, thanks.
> But what do you mean exactly, should I use this method after
> "MessageBox.Show()" ? So "textBox2.Invoke()" in the sample of code I gave
> you
> in the last post ?
>
> Thanks in advance for any information.
>
> "Daniel Moth" wrote:
>
>> Like Chris is implying, chances are you are running that method on a
>> worker
>> thread and hence should use Control.Invoke before touching UI elements:
>> http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html
>>
>> Cheers
>> Daniel
>> --
>> http://www.danielmoth.com/Blog/
>>
>> "Gandalf" <Gandalf@discussions.microsoft.com> wrote in message
>> news:44259113-26A5-40A8-8051-2559258F9AA1@microsoft.com...
>> > Hi,
>> >
>> > Under a Windows CE .NET 4.2 OS, I have a problem with a C# application
>> > which
>> > is the following :
>> > when I call often a routine, my application is blocked on the
>> > MessageBox
>> > and
>> > I must do a reboot of the PDA.
>> >
>> > The routine is the following :
>> >
>> > ---------------------------------------------------------------------
>> > private void routine()
>> > {
>> > MessageBox.Show("Message", "Title");
>> > textBox1.Text = "";
>> > textBox1.Enabled = false;
>> > textBox2.Enabled = true;
>> > textBox2.Text = "";
>> > textBox2.Focus();
>> > }
>> > -------------------------------------------------------
>> > When I debug, I have no message, I can see where the program is
>> > blocking.
>> > I think it's a problem between the MessageBox and the focus on
>> > "textBox2"
>> > field ?
>> >
>> > Thanks for any help.
>> >
>>
>>
>>
>>
>>



Re: C# application is blocked by ctacke/>

ctacke/>
Wed Apr 05 06:38:55 CDT 2006

The point is, what is calling "routine"? In what thread context is it
running? If it's not the UI thread, then calls to UI elements must go
through Invoke.

-Chris


"Gandalf" <Gandalf@discussions.microsoft.com> wrote in message
news:56EA23C0-DF46-426D-80B0-9D750D32DEB9@microsoft.com...
> OK, thanks.
> But what do you mean exactly, should I use this method after
> "MessageBox.Show()" ? So "textBox2.Invoke()" in the sample of code I gave
> you
> in the last post ?
>
> Thanks in advance for any information.
>
> "Daniel Moth" wrote:
>
>> Like Chris is implying, chances are you are running that method on a
>> worker
>> thread and hence should use Control.Invoke before touching UI elements:
>> http://www.danielmoth.com/Blog/2004/10/invoke-cf-and-full-fx.html
>>
>> Cheers
>> Daniel
>> --
>> http://www.danielmoth.com/Blog/
>>
>> "Gandalf" <Gandalf@discussions.microsoft.com> wrote in message
>> news:44259113-26A5-40A8-8051-2559258F9AA1@microsoft.com...
>> > Hi,
>> >
>> > Under a Windows CE .NET 4.2 OS, I have a problem with a C# application
>> > which
>> > is the following :
>> > when I call often a routine, my application is blocked on the
>> > MessageBox
>> > and
>> > I must do a reboot of the PDA.
>> >
>> > The routine is the following :
>> >
>> > ---------------------------------------------------------------------
>> > private void routine()
>> > {
>> > MessageBox.Show("Message", "Title");
>> > textBox1.Text = "";
>> > textBox1.Enabled = false;
>> > textBox2.Enabled = true;
>> > textBox2.Text = "";
>> > textBox2.Focus();
>> > }
>> > -------------------------------------------------------
>> > When I debug, I have no message, I can see where the program is
>> > blocking.
>> > I think it's a problem between the MessageBox and the focus on
>> > "textBox2"
>> > field ?
>> >
>> > Thanks for any help.
>> >
>>
>>
>>
>>
>>