Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WPF -  Can I have two "windows" working  at same time in the same solution?

Posted on 2014-04-07
4
Medium Priority
?
896 Views
Last Modified: 2014-04-08
I'm working on an app that has a usercontrol that is reading at real time emails from Outlook and writing some information in a database. From time to time I want to launch a batch process, with final output on a datagrid  in another user control and comeback to the first one where I will be the most of times! My problem is that the "batch usercontrol" gets locked until the whole process finishes, not allowing me to return to the first. Inside each usercontrol I'm using threading! Can I use among usercontrols?
I'm also using WPF.MDI dll but  any solution is welcomed!
As a Proof of Concept programmer I Thanks in advance!
0
Comment
Question by:novreisb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 35

Expert Comment

by:sarabande
ID: 39985670
generally, the batch process should run in a thread. when it returns with data, you may pass the data by PostMessage calls directed to the parent window of the controls (or an ui controller). the PostMessage would put the messages to the end of the current message queue and you would write a handler that catches the messages and updates the controls accordingly.

alternatively, your thread could put the data into a shared container, and your ui has a timer handler which periodically retrieves the data from the container. you would need to make the access to the container thread-safe by a critical section, a mutex or a lock.

Sara
0
 

Author Comment

by:novreisb
ID: 39985790
Thanks Sara, you give me good ideas
Anyway as I am not english native pheraps  I  was not clear enough. The two usercontrols are children of a midcontainer and I do not need to return data from the "batch user control" to the user control  that is receiving emails. The datagrid I was talking is inside the batch control and I must work on this datagrid after the process finishes. As I like productivity, during the Batch Process I would like to go to the receiving mails control and work here, but I was not able to do that!
This is not going to change your advise, I think,  but it simplifies the problem. I will put the "batch process" on a thread, as you said,  and see if  it releases it to work on the mail control!
0
 
LVL 35

Accepted Solution

by:
sarabande earned 2000 total points
ID: 39985972
if the window of the "batch user control" belongs to a different process it would be valid.

a window controlled by a thread which belongs to the same process as another active window, is not a recommendable solution. the problem is that the thread would need an own message pump which would freeze while reading emails. so you would need a further thread which retrieves mails while the ui thread runs the message pump. windows also doesn't like this way. the new window owned by the thread must create a new "context" such that both the message queues of your process could be properly separated.

I would recommend to choose one of two other ways. one is to integrate the control into the foreground application (thread). that way the "batch" could be a pure worker thread and you could exchange the new mails by messages as I described above. the other is to have a second program (process) for the batch control and emails and use p2p-communication (program-to-program) to control the second program by the first one. you could do that by windows messages or shared memory or network calls (client-server).

Sara
0
 

Author Closing Comment

by:novreisb
ID: 39986200
Thanks very much Sara. I will try those suggestions!
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question