Problem in thread.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Problem in thread.

  1. #1
    Join Date
    Sep 2008
    Posts
    79

    Question Problem in thread.

    Is there any way possible in a windows application
    project to kill the default current thread of the project
    and run a new thread and then relate the project to
    it?

    My case scenario:-
    I have a startup form. In its Load event I want to kill
    the current thread, create a new thread and run the
    project through the new thread. This'll be applicable
    in closing the startup form and open another form.
    When I run, the new thread is being created,
    everything is ok. But as soon as the default/current
    thread is being killed the application is closing down.
    How can I tackle this? Provided, I don't want to hide
    the startup form or stuffs like that.
    Plz help. Regards.

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Problem in thread.

    Why would you want to do this? If you kill the main thread, the application will close. I don't know how you could expect different behavior. Maybe if you tell us what you are trying to accomplish we can propose an alternative method for you.

  3. #3
    Join Date
    Sep 2008
    Posts
    79

    Re: Problem in thread.

    Here's what i want to do. As we have seen, if u try to treat a startup form as a splash form and try to close it and goto the 2nd form the application closes down. If u try to do this by writing the following code in the startup form:
    Application.Run(frm2ndForm);
    this.Close();

    It'll give an error message something like 'More than one message cann't be passed/processed through a single thread. Try using frm2ndForm.ShowDialog();'. Keeping this in mind I'm trying to close the initial thread in which frmStartup is running, create and run a new thread and then open frm2ndForm from it. Hope u understand. Looking forward 4 ur reply. Thanx.

  4. #4
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: Problem in thread.

    Simply just 'show' you splash form and after it run your main form

    Code:
    frmSplash.ShowDialog();
    Application.Run(frmMain);

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center