Click here to Skip to main content
15,913,610 members
Home / Discussions / C#
   

C#

 
GeneralRe: MultiThread and File process Pin
Ilia Blank15-Jan-10 4:29
Ilia Blank15-Jan-10 4:29 
GeneralRe: MultiThread and File process Pin
AlexB4715-Jan-10 4:45
AlexB4715-Jan-10 4:45 
GeneralRe: MultiThread and File process Pin
Ilia Blank15-Jan-10 5:33
Ilia Blank15-Jan-10 5:33 
GeneralRe: MultiThread and File process Pin
AlexB4717-Jan-10 20:42
AlexB4717-Jan-10 20:42 
GeneralRe: MultiThread and File process Pin
Ilia Blank18-Jan-10 4:53
Ilia Blank18-Jan-10 4:53 
GeneralRe: MultiThread and File process Pin
AlexB4718-Jan-10 4:58
AlexB4718-Jan-10 4:58 
GeneralRe: MultiThread and File process Pin
Ilia Blank18-Jan-10 5:04
Ilia Blank18-Jan-10 5:04 
AnswerRe: MultiThread and File process Pin
wjp_auhtm15-Jan-10 3:54
wjp_auhtm15-Jan-10 3:54 
Hi:

I just write a simple example for you. I hope it was useful for you.

<br />
    /// <summary><br />
    /// example of MultiThread<br />
    /// </summary><br />
    class MultiThread<br />
    {<br />
        Thread td_example = null;<br />
        System.Windows.Forms.Control _ctl;<br />
        public MultiThread(System.Windows.Forms.Control ctl)<br />
        {<br />
            td_example = new Thread(new ThreadStart(CalledMethod));<br />
            _ctl = ctl;<br />
        }<br />
<br />
        /// <summary><br />
        /// start the thread<br />
        /// </summary><br />
        public void startThread()<br />
        {<br />
            td_example.Start();<br />
        }<br />
<br />
        /// <summary><br />
        /// pause the thread<br />
        /// </summary><br />
        public void suspendThread()<br />
        {<br />
            td_example.Suspend();<br />
        }<br />
<br />
        /// <summary><br />
        /// stop the thread<br />
        /// Don't forget release the thread by this method<br />
        /// sometimes, the thread willn't exit and still run after the form closed<br />
        /// so, I suggest that to call this method before you want to close the main form.<br />
        /// </summary><br />
        public void abortThread()<br />
        {<br />
            td_example.Abort();<br />
        }<br />
<br />
        int i = 0;<br />
        private void CalledMethod()<br />
        {<br />
            //<br />
            // TODO:write your code here.<br />
            //<br />
            while (true)<br />
            {<br />
                i++;<br />
                System.Windows.Forms.MessageBox.Show(i.ToString());<br />
<br />
                Thread.Sleep(1000);<br />
            }<br />
        }<br />
    }<br />


good luck!
GeneralRe: MultiThread and File process Pin
AlexB4715-Jan-10 4:06
AlexB4715-Jan-10 4:06 
GeneralRe: MultiThread and File process Pin
wjp_auhtm16-Jan-10 2:29
wjp_auhtm16-Jan-10 2:29 
GeneralRe: MultiThread and File process Pin
Luc Pattyn15-Jan-10 5:13
sitebuilderLuc Pattyn15-Jan-10 5:13 
AnswerRe: MultiThread and File process Pin
Alaric Dailey15-Jan-10 6:00
Alaric Dailey15-Jan-10 6:00 
GeneralRe: MultiThread and File process Pin
AlexB4717-Jan-10 20:45
AlexB4717-Jan-10 20:45 
GeneralRe: MultiThread and File process Pin
Alaric Dailey18-Jan-10 4:37
Alaric Dailey18-Jan-10 4:37 
QuestionSystem.InvalidCastException Query Pin
DwR15-Jan-10 2:45
DwR15-Jan-10 2:45 
AnswerRe: System.InvalidCastException Query Pin
DwR16-Jan-10 2:45
DwR16-Jan-10 2:45 
AnswerRe: System.InvalidCastException Query Pin
Eddy Vluggen17-Jan-10 10:50
professionalEddy Vluggen17-Jan-10 10:50 
GeneralRe: System.InvalidCastException Query Pin
FenixTX10-Feb-10 3:52
FenixTX10-Feb-10 3:52 
GeneralRe: System.InvalidCastException Query Pin
Eddy Vluggen10-Feb-10 4:18
professionalEddy Vluggen10-Feb-10 4:18 
QuestionTrap and Read magnetic tripe card reader [modified] Pin
Kaikus14-Jan-10 23:57
Kaikus14-Jan-10 23:57 
AnswerRe: Trap and Read magnetic tripe card reader Pin
OriginalGriff15-Jan-10 0:24
mveOriginalGriff15-Jan-10 0:24 
AnswerRe: Trap and Read magnetic tripe card reader Pin
Roger Wright15-Jan-10 17:29
professionalRoger Wright15-Jan-10 17:29 
QuestionApplication Domain Pin
dataminers14-Jan-10 23:24
dataminers14-Jan-10 23:24 
AnswerRe: Application Domain Pin
EliottA15-Jan-10 2:44
EliottA15-Jan-10 2:44 
AnswerRe: Application Domain Pin
Eddy Vluggen15-Jan-10 3:11
professionalEddy Vluggen15-Jan-10 3:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.