Each Control in a separate thread

Posted on 2006-04-15
Last Modified: 2008-02-26

I am creating a form that contain alot of usercontrols, these user controls is heavy and contain a lot things do,
I want to know a way how to :
When loading the form each control run in a separate thread.

I use some code like that to load the controls:
Dim ctrl1 as new MyUserControlType
Dim ctrl2 as new MyUserControlType
Dim ctrl3 as new MyUserControlType


Please help,

Question by:amrelgarhy81
    LVL 85

    Accepted Solution

    Controls run in the same thread as the form that contains them...

    Did you create the UserControls?  You can make the code INSIDE the UserControls run in a seperate thread.
    LVL 37

    Assisted Solution

    "Did you create the UserControls?  You can make the code INSIDE the UserControls run in a seperate thread."

    Even if you create threads inside of the various controls to handle their tasks it really depends what they are doing as to whether or not there will be a gain. Even if you have multiple threads running in these controls those threads still have to broker any changes to the controls back to the main thread (only the thread that creates a control can access it) as such if your controls are spending their time updating their visual representation even adding additional threads within the controls will not help.
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    This is true.  =)

    It all depends on what we're doing here...

    Can you gives us more details about the UserControl amrelgarhy81?

    Along with a bigger picture of the application?
    LVL 1

    Author Comment


    The application is a small designer application for windows application, and use some user controls i made for it like:
    Scroll Image Control (Load in it number of images to move one after one in run time)
    Custom PictureBox control (Load in it number of images to move one after one in run time)
    Windows media control (playing medias)
    When loading the .exe file that the design create the controls run slow on the form and very slow when loading and closing.
    I thought that running each control in a separate thread  may solve this porformance shortening.
    In these controls like the Scroll Image Control i use a timer to slide the images while running.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Normally a window is moved by clicking on the caption bar and dragging. You may want your user to be able to move borderless forms or move a form by clicking anywhere in the form without the limitation to the caption bar. There are many ways to do i…
    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now