Results 1 to 3 of 3

Thread: WinForms and Threading Question/Problem

  1. #1

    Thread Starter
    Hyperactive Member kleptos's Avatar
    Join Date
    Aug 2001
    Location
    The Dark Carnival
    Posts
    346

    Unhappy WinForms and Threading Question/Problem

    I have a windows application that grabs an XML file, parses the XML and grabs the fields, and then writes the data to a text file. (It will go into a database once i figure the problem out.) I can parse the XML file, i can write it to a file, my problem is that it takes about 1 minute to parse the XML file, its huge, i cant do anythign else on the form, i cant even minimize the form until the parsing completes. This is a problem, i need to be able to do other things while this thing is parsing. So i added threads, and that works, i have it parsing in its own thread, but same problem occures. I cant do anthing else to the app once the parser starts. I must wait till it completes, how can i get around this? I thought threads would be my answer, and maybe it still is, i am just missing something. Thanks for the help.
    ..::[kleptos]::..
    • Database Administrator (MSSQL 2000)
    • Application Developer (C#)
    • Web Developer (ASP.NET)


  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403
    How does your thread work? off the top of my head, this is how I'd do it...
    PHP Code:
    using System.Threading;

    void BtnParse_Click(object senderSystem.EventArgs e)
    {
        
        
    Thread tXmlThread = new Thread(new ThreadStart(myXMLproc) );
        
    tXmlThread.Start();

    }

    void myXMLproc()
    {
        
    // let the user know what's going on...
        
    myStatusBar.Text "Processing XML File...."

        
    while(not_done_processing); // do your stuff

        
    myStatusBar.Text "Done Processing XML File!"
        
    MessageBox.Show("XML Parsing complete!");
        
        return;

    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3

    Thread Starter
    Hyperactive Member kleptos's Avatar
    Join Date
    Aug 2001
    Location
    The Dark Carnival
    Posts
    346
    This code is in my main form.
    PHP Code:
    private void btnParse_Click(object senderSystem.EventArgs e)

         
    Parser p = new Parser();
         
    p.ParseXML();

    This code is my parser class.
    PHP Code:
    public void ParseXML()
    {
         
    Thread t1 = new Thread(new ThreadStart(ParseFile));
         
    t1.IsBackground true;
         
    t1.Start();

    The rest is what grabs the file and parses it. Nothing related to the threads is in that.
    ..::[kleptos]::..
    • Database Administrator (MSSQL 2000)
    • Application Developer (C#)
    • Web Developer (ASP.NET)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width