Click here to Skip to main content
15,889,931 members
Home / Discussions / C#
   

C#

 
GeneralRe: About EndInvoke Pin
Bob_Sun13-Apr-06 21:55
Bob_Sun13-Apr-06 21:55 
GeneralRe: About EndInvoke Pin
Tehnoon13-Apr-06 22:24
Tehnoon13-Apr-06 22:24 
GeneralRe: About EndInvoke Pin
Bob_Sun13-Apr-06 22:55
Bob_Sun13-Apr-06 22:55 
GeneralRe: About EndInvoke Pin
Daniel Grunwald13-Apr-06 23:14
Daniel Grunwald13-Apr-06 23:14 
GeneralRe: About EndInvoke Pin
Bob_Sun13-Apr-06 23:18
Bob_Sun13-Apr-06 23:18 
GeneralRe: About EndInvoke Pin
Daniel Grunwald13-Apr-06 23:41
Daniel Grunwald13-Apr-06 23:41 
AnswerRe: About EndInvoke Pin
Tehnoon14-Apr-06 0:21
Tehnoon14-Apr-06 0:21 
GeneralRe: About EndInvoke Pin
Bob_Sun16-Apr-06 14:37
Bob_Sun16-Apr-06 14:37 
Tehnoon wrote:
Can you show the code in which you are invoking the thread which is creating the problem? Garbage collection will not be done unless the thread is finished with the execution. The only possibility that I am seeing here is that the system is not being able to provide all the requested resources by the program and hence the results are not coming out as expected. A look at the source code will give me a better idea of this.


Sorry for a late response.
A statemachine exists in my program, and all the events are dispatched to it by seperate threads.The code is something like the following.

public class Control
{
    private StateMachine myStateMachine = new StateMachine();

    public void EventProc1()
    {
        ....
        EventHandler eventHandler = new EventHandler(this.Thread1);
        eventHandler.BeginInvoke(this,null,null,null);
    }

    public void EventProc2()
    {
        ....
        EventHandler eventHandler = new EventHandler(this.Thread2);
        eventHandler.BeginInvoke(this,null,null,null);
    }

    protected void Thread1(object sender,EventArgs e)
    {
        LogMessage("Start of thread1");
        this.myStateMachine.Dispatch(1);
    }

    protected void Thread2(object sender,EventArgs e)
    {
        LogMessage("Start of thread2");
        this.myStateMachine.Dispatch(2);
    }
}

public class StateMachine
{
    public void Dispatch(event id)
    {
        switch(event id)
        {
            case 1:
                ....
                break;
            case 2:
                ....
                break;
            ...
            default:
                break;
        }
    }
}

Up to now, many phenomena happened, such as although the LogMessage were logged in log file, the thread just stopped somewhere afterward. Or sometimes, one thread should be waiting for an AutoResetEvent which must be set in another thread as designed, but the previous thread moves on before the AutoResetEvent is Set()...

Another important supplement is that GC.Collect() is executed in another thread, ie. in EventProc1().

I have written many test programs so as to find the real reason, and still don know where a memory leak brought by no-EndInvoke will lead to the above phenomena.

Looking forword to your help.

Thank you!
QuestionEncoding class Pin
manish ojha13-Apr-06 13:06
manish ojha13-Apr-06 13:06 
AnswerRe: Encoding class Pin
Dave Kreskowiak13-Apr-06 13:10
mveDave Kreskowiak13-Apr-06 13:10 
AnswerRe: Encoding class Pin
Stefan Troschuetz13-Apr-06 13:20
Stefan Troschuetz13-Apr-06 13:20 
AnswerRe: Encoding class Pin
Bob_Sun13-Apr-06 23:23
Bob_Sun13-Apr-06 23:23 
QuestionIs there a easy way to remove the black border around a Forms.Button? Pin
qtran020313-Apr-06 10:57
qtran020313-Apr-06 10:57 
AnswerRe: Is there a easy way to remove the black border around a Forms.Button? Pin
Office Lineman13-Apr-06 12:40
Office Lineman13-Apr-06 12:40 
AnswerRe: Is there a easy way to remove the black border around a Forms.Button? Pin
spoone13-Apr-06 15:33
spoone13-Apr-06 15:33 
QuestionUploading a file Pin
Sean8913-Apr-06 10:37
Sean8913-Apr-06 10:37 
AnswerRe: Uploading a file Pin
jeweladdict13-Apr-06 10:49
jeweladdict13-Apr-06 10:49 
GeneralRe: Uploading a file Pin
Sean8913-Apr-06 11:00
Sean8913-Apr-06 11:00 
GeneralRe: Uploading a file Pin
jeweladdict13-Apr-06 11:03
jeweladdict13-Apr-06 11:03 
GeneralRe: Uploading a file Pin
Sean8913-Apr-06 11:08
Sean8913-Apr-06 11:08 
AnswerRe: Uploading a file Pin
Guffa13-Apr-06 11:20
Guffa13-Apr-06 11:20 
AnswerRe: Uploading a file Pin
Guffa13-Apr-06 11:22
Guffa13-Apr-06 11:22 
GeneralRe: Uploading a file Pin
Sean8913-Apr-06 11:40
Sean8913-Apr-06 11:40 
AnswerRe: Uploading a file Pin
Guffa13-Apr-06 12:11
Guffa13-Apr-06 12:11 
GeneralRe: Uploading a file Pin
Sean8913-Apr-06 12:50
Sean8913-Apr-06 12:50 

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.