handling threads in .net compact framework..

Posted on 2004-11-04
Last Modified: 2008-01-09
I am writing a program for pocketpc, using 2003
but i can only use Thd.start(), but can't use .Abort() or suspend

any way to solve this problem?

it is very urgent, extra points will be awarded...
thanks !!!
Question by:ho_alan
    LVL 21

    Expert Comment

    Because the .NET Compact Framework does not support the Thread.Abort and Thread.Stop methods, an application should stop all thread processes before allowing itself to close.
    LVL 21

    Assisted Solution

    LVL 3

    Accepted Solution

    For reference

    Closing threaded applications

    Because the .NET Compact Framework does not support the Thread.Stop and Thread.Abort methods, you must be sure that no threads are running when you close a form. This QuickStart overrides the OnClosing method to cancel closing the form when the OK button, in the upper-right corner of the form, is clicked.

    Note that a Pocket PC application with an OK button closes the form, and an application with an X button minimizes the form. For information about switching these buttons, see the Pocket PC Form Styles QuickStart. This QuickStart requires an OK button so that the Closing event is raised in order to use the OnClosing method.

    Both the OnClosing and CloseButton_Click methods, as shown in the following code example, set the codeRequested variable to true. Only when the thread determines that this variable is true in the ThreadProc method does the thread close the form. The thread closes the form by using ControlInvoker.Invoke to invoke the CloseForm method.

    // Set the closeRequested variable to true. This ensures that the
    // Close button will not allow the application to close unless
    // the thread has stopped running. When the ThreadProc method
    // determines that closeRequested is true, it closes the application.
    private void CloseButton_Click(object sender, System.EventArgs e) {
          closeRequested = true;

    // The OnClosing override is called when the user clicks the OK
    // button so that the application does not close until the thread
    // has stopped running.
    protected override void OnClosing(CancelEventArgs e)
       if (this.threadRunning)      
          e.Cancel = true;
          MessageBox.Show("Application will close when thread has stopped running.");
      closeRequested = true;

    LVL 5

    Author Comment

    thanks all

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    733 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

    22 Experts available now in Live!

    Get 1:1 Help Now