two windows & 2 threads

D

DM

Hello.

In my app I have two threads and two windows. Each window
is created and managed by a different thread. Everything works
fine except for one thing. When I click on the window which was
created
first, on screen of my PocketPC appears this twirling circle
as if system was busy doing something. If the other window has focus
the circle disappears.
Is there some way I can prevent the circle from displaying?

Thanks for any suggestions.
 
J

Jon Skeet [C# MVP]

DM said:
In my app I have two threads and two windows. Each window
is created and managed by a different thread.

Why? This is almost always a bad idea - it'll make things much more
complicated.
 
D

DM

Jon Skeet said:
Why? This is almost always a bad idea - it'll make things much more
complicated.

I believe it is not in this case. It's justified be internal
desing of the application.
 
C

Chris Tacke, eMVP

The user can only interact with one UI at a time so it's extremely rare to
have a situation that warrants multiple message pumps in a single app. Why
exactly do you think you need two UI threads?

-Chris




DM said:
Jon Skeet [C# MVP] <[email protected]> wrote in message
Why? This is almost always a bad idea - it'll make things much more
complicated.

I believe it is not in this case. It's justified be internal
desing of the application.
 
J

Jon Skeet [C# MVP]

DM said:
I believe it is not in this case. It's justified be internal
desing of the application.

But what is that justification? What is actually improved by this?
 
D

DM

Chris Tacke said:
The user can only interact with one UI at a time so it's extremely rare to
have a situation that warrants multiple message pumps in a single app. Why
exactly do you think you need two UI threads?
Because those 2 windows are createad by 2 separate moudles of my app,
which are run by 2 differenect threads and there is no easy way they
can interact
- just by passing messages. To have one gui thread I would have to
create
another module (with another one thread), use messages to inform other
modules what user asks them to do, use Invoke..... Lots of unnecessary
work.

Does anyone actually knows a solution to my problem?
 
C

Chris Tacke, eMVP

Have you created two completely separate message pumps? I don't think you
can use Application.Run, you probably have to manually do it. As has been
indicated, management won't be fun, but there's no reason that it won't
work.

-Chris


DM said:
"Chris Tacke, eMVP" <ctacke[at]OpenNETCF_dot_org> wrote in message
The user can only interact with one UI at a time so it's extremely rare to
have a situation that warrants multiple message pumps in a single app. Why
exactly do you think you need two UI threads?
Because those 2 windows are createad by 2 separate moudles of my app,
which are run by 2 differenect threads and there is no easy way they
can interact
- just by passing messages. To have one gui thread I would have to
create
another module (with another one thread), use messages to inform other
modules what user asks them to do, use Invoke..... Lots of unnecessary
work.

Does anyone actually knows a solution to my problem?
 
S

Serg Kuryata [MS]

What are those windows? Are they just two forms? Please could you post some
code that shows how you create and show them?

Thank you
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (DM)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Re: two windows & 2 threads
| Date: 13 Sep 2004 00:33:25 -0700
| Organization: http://groups.google.com
| Lines: 18
| Message-ID: <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| NNTP-Posting-Host: 83.31.215.242
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1095060806 395 127.0.0.1 (13 Sep 2004
07:33:26 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Mon, 13 Sep 2004 07:33:26 +0000 (UTC)
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwi
x.com!newsfeed.cwix.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news
.glorb.com!postnews2.google.com!not-for-mail
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:61075
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| "Chris Tacke, eMVP" <ctacke[at]OpenNETCF_dot_org> wrote in message
| > The user can only interact with one UI at a time so it's extremely rare
to
| > have a situation that warrants multiple message pumps in a single app.
Why
| > exactly do you think you need two UI threads?
| >
| Because those 2 windows are createad by 2 separate moudles of my app,
| which are run by 2 differenect threads and there is no easy way they
| can interact
| - just by passing messages. To have one gui thread I would have to
| create
| another module (with another one thread), use messages to inform other
| modules what user asks them to do, use Invoke..... Lots of unnecessary
| work.
|
| Does anyone actually knows a solution to my problem?
|
| --
| DM
|
 
D

DM

What are those windows? Are they just two forms? Please could you post some
code that shows how you create and show them?
The first form is created in standard way (i.e. code generated by VS
..NET )

This is the how I create another from and I don't see anything odd
in this code:

class ModStatus
{
....
public void Run()
{
new Thread(new ThreadStart(this.Start)).Start();
}
private void Start()
{
Application.Run( new ModStatusForm(this) );
}
....
}

Of course ModStatusForm inherits after System.Windows.Form.
The twirling circle (sorry, I don't know hot it is called ) appears
when the form (i.e. thread with message pump) which actually calls
ModStatus.Run has focus.
 
D

DM

Chris Tacke said:
Have you created two completely separate message pumps? I don't think you
can use Application.Run, you probably have to manually do it. As has been
indicated, management won't be fun, but there's no reason that it won't
work.
Yes, I call Application.Run from newly created thread.

What do you mean by - manually?

Thanks.
 
S

Serg Kuryata [MS]

Unfortunately, the scenario that you are trying to implement is not really
supported in V1. The problem is that the .NET Compact Framework has a quite
week support for multithreading in GUI. Though, this problem has been fixed
in V2. I wrote a simple application that implements your scenario and it
worked just fine when I ran it against the .NET Compact Framework V2.

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (DM)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Re: two windows & 2 threads
| Date: 14 Sep 2004 01:25:38 -0700
| Organization: http://groups.google.com
| Lines: 32
| Message-ID: <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| NNTP-Posting-Host: 83.31.243.186
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1095150339 15137 127.0.0.1 (14 Sep 2004
08:25:39 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Tue, 14 Sep 2004 08:25:39 +0000 (UTC)
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08
phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news.glorb.com!postnews2.goo
gle.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:61138
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| (e-mail address removed) (Serg Kuryata [MS]) wrote in message
| > What are those windows? Are they just two forms? Please could you post
some
| > code that shows how you create and show them?
| >
| The first form is created in standard way (i.e. code generated by VS
| .NET )
|
| This is the how I create another from and I don't see anything odd
| in this code:
|
| class ModStatus
| {
| ....
| public void Run()
| {
| new Thread(new ThreadStart(this.Start)).Start();
| }
| private void Start()
| {
| Application.Run( new ModStatusForm(this) );
| }
| ....
| }
|
| Of course ModStatusForm inherits after System.Windows.Form.
| The twirling circle (sorry, I don't know hot it is called ) appears
| when the form (i.e. thread with message pump) which actually calls
| ModStatus.Run has focus.
|
|
| --
| DM
|
 
C

Chris Tacke, eMVP

By manually I mean actually write the code for both message pumps. P/Invoke
the Peek/Dispatch message APIs, etc. so you have full control. Basically
throw Application.Run out the window and roll your own.

-Chris

DM said:
"Chris Tacke, eMVP" <ctacke[at]OpenNETCF_dot_org> wrote in message
Have you created two completely separate message pumps? I don't think you
can use Application.Run, you probably have to manually do it. As has been
indicated, management won't be fun, but there's no reason that it won't
work.
Yes, I call Application.Run from newly created thread.

What do you mean by - manually?

Thanks.
 
D

D M

Thanks.

Would it be difficult, could you give me a hint
how to start or point some code?

Do I really have to manually dispatch messages for both
threads? This extra thread only diplays window with a few
controls, whereas the main thread manages a lots of them.
 
D

D M

Hmm.

I changed a ApplicationEx a bit - so it is not single thread
oriented as orgianally. I can now call ApllicationEx.Run(Form)
from several threads and each thread does it's own pumping
but the circle still twirls.

Seigh.
 
C

Chris Tacke, eMVP

When does the wait icon appear? On thread creation? Second Form? Try
seeting the icon back to default right after the place where it appears. If
you need better control of the situation, look at the ThreadEx class.

-Chris
 
D

D M

Well, situation is worse than I initially thought.

When I call a ShowDialog on a form and this form displays
another one also with ShowDialog the other thread just freezes
- does not seem to be receiving any messages.
 
S

Serg Kuryata [MS]

.NETCF V1 does not support multithreaded GUI scenarios. That's why you are
seeing these problems.

Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: D M <[email protected]>
| References: <[email protected]>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: Re: two windows & 2 threads
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Date: Mon, 20 Sep 2004 01:10:52 -0700
| NNTP-Posting-Host: 67.41.129.85
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:61541
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
|
| Well, situation is worse than I initially thought.
|
| When I call a ShowDialog on a form and this form displays
| another one also with ShowDialog the other thread just freezes
| - does not seem to be receiving any messages.
|
|
| --
| DM
|
|
|
|
| Don't just participate in USENET...get rewarded for it!
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top