2

I am working with a team on an application that has a report generator and then a report viewer. At the moment we have not been able to open up the report viewer in a separate thread. These two applications should be independent once opened, and if one is closed it should not effect the other.

The Report Viewer has one UI set of files and the main UI has another set. My question is how can we open up the Viewer UI in a separate thread once the main UI is back in it's "idle" state (not hidden, just not processing anything)?

Any short code snippets would be helpful, at this point I am completely lost on how to open up the viewer in a new thread...

5
  • 3
    ANy reason why they cannot be separate executables? Commented Aug 22, 2012 at 17:57
  • 4
    Why would you need them to be in different threads? They can be basically independent, but still have the same UI thread, so long as the rest of your code obeys the normal threading rules (so doesn't hog the UI thread). Commented Aug 22, 2012 at 17:57
  • A similar post: stackoverflow.com/questions/5570140/… Commented Aug 22, 2012 at 17:59
  • I would suggest you make them separate processes (ie. two different executables) and have the generator launch the viewer [probably] with the necessary command line arguments to view the report. Running UI components on different threads is difficult if not dangerous, Windows isn't really designed to do such things. Commented Aug 22, 2012 at 17:59
  • Can't your ReportViewer just be another Form that is shown with Form.Show from the main form? You don't need a separate thread for this. Commented Aug 22, 2012 at 18:56

1 Answer 1

1

Perhaps something along the lines of this:

private void MethodName { System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc)); t.Start(); } 

and the ThreadProc code will look like this:

public static void ThreadProc() { Application.Run(new Application_Name()); } 

MethodName (for me) is actually

serverToolStripMenuItem_Click(object sender, EventArgs e) 

As it is an event-driven code.

Application_Name will be the form or Application you want to run.

Hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

Tudor noted that you could us a Form.Show(); event to open another form whilst keeping the old one open, or hiding it. If you need it to be separately threaded, Form.Show(); won't work for that, but it is a smooth way to interact with forms.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.