locked
C#: How to run a "Loading" form prompt while downloading files? RRS feed

  • Question

  • How would I run a "Loading" form prompt while downloading files? Below is what I have tried, which works, EXCEPT I lose the ability to close/minimize the form in case the user wants to cancel the application or move the form message.  I figure I have to use some form of threading but have been unsuccessful.  I've tried Parallel tasks and Threading but they still don't allow the interactiveness of the form. I suspect it is simple and I may stumble upon it, but maybe some can share an idea. This code is my testing project in attempting to learn how to get it to work.

    Thanks,

    namespace Test_Loading_Prompt
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                Form2 Loading = new Form2();   // Create form2 (Loading)
                Loading.Show();                // Launch form2
                Sleeping();                    // Call to procedure prior to opening form1
                Loading.Close();                // Close form2 (Loading)
            }
            
            private void Sleeping()
            {
                Thread.Sleep(10000);
            }
        }
    }


    SV

    • Moved by CoolDadTx Monday, December 22, 2014 5:38 PM Winforms related
    Monday, December 22, 2014 4:14 PM

Answers

  • You can look at BackgroundWorker class

    If you get your question answered, please come back and Alternate TextMark As Answer.
    Web Developer

    • Marked as answer by Carl Cai Monday, December 29, 2014 10:40 AM
    Monday, December 22, 2014 4:23 PM