Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a project that runs in its own thread
Message
From
20/08/2008 15:27:39
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01340388
Message ID:
01340505
Views:
7
>>Hi all,
>>
>>I have a project in my solution that is a wrapper class around a third party product. I want this entire project to run in it's own thread. I understand threading but not sure how to get the whole project in its own thread. I don't want to do this in the using application.
>>
>>I have one primary class in this project and some supporting classes.
>>Thanks for any helpful direction.
>>Thanks
>>Tim
>
> If you have one "main" entrypoint into that other project you can do this either in the calling application (or, what I think you want) in the project itself. Just move the startup code into another method and replace the startup code with a new thread call to that other method:
>
>
>public static System.Threading.Thread AppThread { get; set; }
>
>public void MainEntry()
>{
>    AppThread = new System.Threading.Thread(new System.Threading.ThreadStart(CodeThatUsedToBeInMainEntry));
>    AppThread.Start();
>
>}
>
>public void CodeThatUsedToBeInMainEntry()
>{
>   // Do something
>}
>
>
>All the code should then be running in the new thread.

Hi Paul,

Thanks for your response as always. I may have to make some changes to the way I am doing this since I am using a singleton on this class. I probably don't need to since I now have a application property to get access. Here is my code now. Then to access this I just instantiate the class and call the MainEntry and that puts everything else into a seperate thread?
public class IntermecWrapper : System.ComponentModel.Component
{
     #region Singleton

     private static IntermecWrapper instance = null;
     public static IntermecWrapper Instance
     {
          get
          {
               if(instance == null)
                    instance = new IntermecWrapper();

               return instance;
          }
     }

     /// <summary>
     /// Constructor
     /// Private due to Singleton use
     /// </summary>
     private IntermecWrapper()
     {
          this.InitializeComponent();

          // Create the Rfid Settings Class
          RfidSettings.Load();
     }

     #endregion Singleton
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform