dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Questions

Threaded View

  1. #1
    Join Date
    Aug 2009
    Posts
    18

    Questions

    Hi, i'm gonna be working on a new miniproject soon but i need some information before starting; since i believe that Programing with everything planned ahead makes for painless coding !

    Question 1
    As much as i know, there is no OnLoaded event for WinForms, that would be handled when ALL Components of a Form are Loaded and displayed.
    There is only an OnShown event but it only concerns the Form.

    How can i make it so that my Code only runs after all components are fully loaded ?
    i thought about setting a 3 Seconds TimeLap using either Thread.Sleep(3000) or maybe Timer
    But where can i even put it, since it will probably be activated BEFORE THE FORM & it's components are displayed, this is a problem i've been looking to resolve but found no way besides implementing a button and using it's click event, which i don't need .

    Question 2.
    As my Download will have to run on a secondary thread in order not to block the app , i will have to update the Status label's text which was created on the MAIN Thread. How does one do Cross thread opérations such as this one?

    I Heard about 2 things :
    Invoke , but i don't know how it works and i couldn't grasp the concept from the info here, if someone could explain.
    or System.Windows.Form.Control.CheckforIllegalCrossThread set to false !
    which is reported as dangerous, and it seems that MSDN Says that it does not work outside of the debuger?

    Question 3
    A Problem with the progress Bar,
    for the Download , i Believe that to use the Progress Bar control the download has to be Async but my download méthod having already started on a second thread, i don't think that i would need it to be async especially considering that the progress bar is on the main thread (am i right?)
    So how can i use it with DownloadFile instead of Async ?

    The reason is that if i use ASYNC, the Code won't stop and i believe that Thread.Suspend or Wait has been removed from Visual Studio for some reason ,
    and if the code following is executed, it will screw the progress Bar as the Download of the next file will also happen simultaneously which the progress bar can't naturally handle.
    So the solutions i can think of here are :
    - Find a way to stop code execution until completition of Download that is on going.
    - Use DownloadFile as it always blocks until file is completely downloaded


    I Realize there are a lot of questions, but don't hesitate to just throw one idea , thanks !
    Last edited by Rehael; August 15th, 2009 at 06:53 AM.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)