Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Thread running correctly but not waiting for user input!

$
0
0

Hi everyone!

I've made a database application. When a user chooses to run a report, it takes time to load up. In that time, the user cannot click anywhere else otherwise the program says its not responding.

So, I've made a thread and the report opens up on another thread. This thread opens up a form which in turn opens up the report, etc.

The problem is that the thread starts, it all opens up but quickly disappears! That's not what I had in mind! I want the thread to open up the form then wait until user input. When the form is closed then the thread should abort/join.

Anyone got any ideas on how I can make the thread wait?

METHOD 1

Thread t = new Thread(ShowReport);
t.Start(parameters);



METHOD 2

        public static void ShowReport(object obj)
        {
            try
            {
                object[] dd = (object[])obj;

                string pathOrAlias = (string)dd[0];
                ReportParameterCollection coll = (ReportParameterCollection)dd[1];
                bool showParamPrompts = (bool)dd[2];
                int printerIndex = (int)dd[3];

                frmReportViewer rpt = new frmReportViewer(PrepareReport(pathOrAlias, coll, out showParamPrompts, out printerIndex), showParamPrompts, printerIndex);
                //rpt.MdiParent = FormFunc.GetForm("frmMain");
                rpt.Show();
                rpt.Visible = true;
            }
            catch (Exception ex)
            {
                MiscFunc.ShowErrorMessage(ex, false);
            }
        }

This is my rough test code which doesn't really work!

Cheers...


I'm a Compsci student


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>