Click here to Skip to main content
15,914,413 members
Home / Discussions / C#
   

C#

 
Questionhow to embedded exe in design time and extract it at runTime ? Pin
hdv2129-Apr-07 7:36
hdv2129-Apr-07 7:36 
AnswerRe: how to embedded exe in design time and extract it at runTime ? Pin
Colin Angus Mackay9-Apr-07 7:40
Colin Angus Mackay9-Apr-07 7:40 
GeneralRe: how to embedded exe in design time and extract it at runTime ? Pin
hdv2129-Apr-07 8:18
hdv2129-Apr-07 8:18 
GeneralRe: how to embedded exe in design time and extract it at runTime ? Pin
Colin Angus Mackay9-Apr-07 9:05
Colin Angus Mackay9-Apr-07 9:05 
QuestionHow to add "Check Mark" to a Context Menu? Pin
Khoramdin9-Apr-07 7:21
Khoramdin9-Apr-07 7:21 
AnswerRe: How to add "Check Mark" to a Context Menu? Pin
kubben9-Apr-07 7:29
kubben9-Apr-07 7:29 
Questionpath 2 get image file from resource Pin
samreengr89-Apr-07 7:00
samreengr89-Apr-07 7:00 
AnswerRe: path 2 get image file from resource Pin
Luc Pattyn9-Apr-07 9:21
sitebuilderLuc Pattyn9-Apr-07 9:21 
GeneralRe: path 2 get image file from resource Pin
samreengr89-Apr-07 11:00
samreengr89-Apr-07 11:00 
GeneralRe: path 2 get image file from resource Pin
Luc Pattyn9-Apr-07 13:57
sitebuilderLuc Pattyn9-Apr-07 13:57 
QuestionSystem.Diagnostics.Design? Pin
Vodstok9-Apr-07 6:17
Vodstok9-Apr-07 6:17 
AnswerRe: System.Diagnostics.Design? Pin
Colin Angus Mackay9-Apr-07 6:23
Colin Angus Mackay9-Apr-07 6:23 
GeneralRe: System.Diagnostics.Design? Pin
Vodstok9-Apr-07 7:13
Vodstok9-Apr-07 7:13 
GeneralRe: System.Diagnostics.Design? Pin
Colin Angus Mackay9-Apr-07 7:37
Colin Angus Mackay9-Apr-07 7:37 
GeneralRe: System.Diagnostics.Design? Pin
Vodstok9-Apr-07 7:43
Vodstok9-Apr-07 7:43 
AnswerRe: System.Diagnostics.Design? Pin
Dan Neely9-Apr-07 7:11
Dan Neely9-Apr-07 7:11 
QuestionWhere is my memory? [modified] Pin
lak-b9-Apr-07 5:17
lak-b9-Apr-07 5:17 
AnswerRe: Where is my memory? Pin
S. Senthil Kumar9-Apr-07 6:36
S. Senthil Kumar9-Apr-07 6:36 
GeneralRe: Where is my memory? Pin
lak-b9-Apr-07 7:49
lak-b9-Apr-07 7:49 
GeneralRe: Where is my memory? Pin
S. Senthil Kumar9-Apr-07 9:28
S. Senthil Kumar9-Apr-07 9:28 
QuestionDecorator Pattern Related Question Pin
jubilanttiger9-Apr-07 4:31
jubilanttiger9-Apr-07 4:31 
AnswerRe: Decorator Pattern Related Question Pin
Leslie Sanford9-Apr-07 6:14
Leslie Sanford9-Apr-07 6:14 
QuestionThread Aorting Pin
HexaDeveloper9-Apr-07 3:37
HexaDeveloper9-Apr-07 3:37 
AnswerRe: Thread Aorting Pin
Leslie Sanford9-Apr-07 5:32
Leslie Sanford9-Apr-07 5:32 
HexaDeveloper wrote:
i tried to abort thread but when i make
myThread.Abort();
it give me an exception of aborting thread so what can i do to avoid this exception


Allow the thread to end naturally. Typically, a thread method has a loop that it runs until it completes its task.

private void ThreadMethod
{
    while(notDone)
    {
        // Do stuff here...
    }
}


HexaDeveloper wrote:
another thing is that Suspend Method is obsolete(help said)
what is the alternative


Hmm, well you could use locking to pause a thread:

private void ThreadMethod
{
    lock(lockObject)
    {
        Monitor.Wait(lockObject);
    }
 
    while(!done)
    {
        // Do stuff here...
    }       
}


And at the point in which you create the thread:

Thread myThread = new Thread(ThreadMethod);
 
myThread.Start();
 
lock(lockObject)
{
    Monitor.Pulse(lockObject);
}


This will create a thread and start it. The thread runs until it reaches the Monitor.Wait(lockObject) statement. At that point, it's up to you to wake up the thread and let it do its thing. This is done above with the Monitor.Pulse(lockObject) statement.

Now, often times you want a thread to wait periodically instead of just when it's started up. So we can put a Wait inside the loop:

private void ThreadMethod
{
    lock(lockObject)
    { 
        while(!done)
        {
            Monitor.Wait(lockObject);
 
            if(done)
            {
                break;
            }
 
            // Do stuff here...
        }       
    }
}


Then it's up to your application to periodically wake up the thread to do its work. Hope this helps.

HexaDeveloper wrote:
third and last:
when i declare thread as member data in class it refuses to identify the name of the method i used to initialize
like:


This question I don't understand. Can you elaborate?
GeneralRe: Thread Aorting [modified] Pin
HexaDeveloper10-Apr-07 14:01
HexaDeveloper10-Apr-07 14:01 

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.