Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: RegistryKey showing Object reference not set to an instance of an object Pin
Jassim Rahma9-Jan-15 11:50
Jassim Rahma9-Jan-15 11:50 
QuestionPlay a video Pin
AlecJames9-Jan-15 8:50
AlecJames9-Jan-15 8:50 
QuestionHaving issues with a action looping Pin
Member 113620598-Jan-15 7:12
Member 113620598-Jan-15 7:12 
AnswerRe: Having issues with a action looping Pin
Pete O'Hanlon8-Jan-15 7:26
mvePete O'Hanlon8-Jan-15 7:26 
GeneralRe: Having issues with a action looping Pin
Member 113620598-Jan-15 7:48
Member 113620598-Jan-15 7:48 
GeneralRe: Having issues with a action looping Pin
Pete O'Hanlon8-Jan-15 9:11
mvePete O'Hanlon8-Jan-15 9:11 
GeneralRe: Having issues with a action looping Pin
Member 113620598-Jan-15 9:49
Member 113620598-Jan-15 9:49 
AnswerRe: Having issues with a action looping Pin
BillWoodruff8-Jan-15 8:37
professionalBillWoodruff8-Jan-15 8:37 
The issue of "involuntary recursion" is sometimes something you can't avoid having to handle: for example, events of certain WinForm Controls will be called when a Form is initialized, which may trigger side-effects that need to be stopped.

If you can't easily re-design your flow-of-control to eliminate this problem, then a "fix" is to:

0. first test to see if setting 'm_facing is triggering the recursion: create a boolean variable in Form scope:
C#
private bool dontRecurse = false;

// use that variable like this:

private void MyMethod(...)
{
    if(dontRecurse) return;

    dontRecurse = true;

    switch(...)
    {
        case Ability.TurnRight:

        switch (m_facing)
        {
            case World.Direction.North:
            m_facing = World.Direction.East;
            break;
    
            case World.Direction.South:
            m_facing = World.Direction.West;
            break;
    
            case World.Direction.East:
            m_facing = World.Direction.South;
            break;
    
            case World.Direction.West:
            m_facing = World.Direction.North;
            break;
        }
    }

    dontRecurse = false;
}
Observe if this fixes the problem: if it does not then:

1. using the debugger: set a break-point in the code where you the first change occurs: in your case that would in one of the Switch/Case clauses before 'm_facing is set.

2. run your code making sure you trigger a case where you hit the break-point, and then single-step (F11) from the break-point to isolate what is triggering the re-execution of the the case statement.

When you have a clear understanding of what triggers the recursion, then re-design or use boolean flag as necessary.
«A man will be imprisoned in a room with a door that's unlocked and opens inwards ... as long as it does not occur to him to pull rather than push»  Wittgenstein

GeneralRe: Having issues with a action looping Pin
Member 113620598-Jan-15 9:50
Member 113620598-Jan-15 9:50 
QuestionConvert from Base 64 to hexadecimal value Pin
NJdotnetdev8-Jan-15 7:10
NJdotnetdev8-Jan-15 7:10 
AnswerRe: Convert from Base 64 to hexadecimal value Pin
SledgeHammer018-Jan-15 7:25
SledgeHammer018-Jan-15 7:25 
GeneralRe: Convert from Base 64 to hexadecimal value Pin
NJdotnetdev8-Jan-15 7:32
NJdotnetdev8-Jan-15 7:32 
AnswerRe: Convert from Base 64 to hexadecimal value Pin
PIEBALDconsult8-Jan-15 7:32
mvePIEBALDconsult8-Jan-15 7:32 
GeneralRe: Convert from Base 64 to hexadecimal value Pin
NJdotnetdev8-Jan-15 7:34
NJdotnetdev8-Jan-15 7:34 
GeneralRe: Convert from Base 64 to hexadecimal value Pin
PIEBALDconsult8-Jan-15 7:42
mvePIEBALDconsult8-Jan-15 7:42 
GeneralRe: Convert from Base 64 to hexadecimal value Pin
NJdotnetdev13-Jan-15 8:48
NJdotnetdev13-Jan-15 8:48 
Questionusing sData in C# to post sales Pin
Jassim Rahma7-Jan-15 20:33
Jassim Rahma7-Jan-15 20:33 
AnswerRe: using sData in C# to post sales Pin
Mycroft Holmes7-Jan-15 21:02
professionalMycroft Holmes7-Jan-15 21:02 
AnswerRe: using sData in C# to post sales Pin
Richard MacCutchan7-Jan-15 22:51
mveRichard MacCutchan7-Jan-15 22:51 
QuestionABOUT C# PROJECT Pin
bhulku Swati7-Jan-15 16:33
bhulku Swati7-Jan-15 16:33 
AnswerRe: ABOUT C# PROJECT Pin
BillWoodruff7-Jan-15 16:55
professionalBillWoodruff7-Jan-15 16:55 
AnswerRe: ABOUT C# PROJECT Pin
Pete O'Hanlon7-Jan-15 20:29
mvePete O'Hanlon7-Jan-15 20:29 
AnswerRe: ABOUT C# PROJECT Pin
Swinkaran8-Jan-15 10:12
professionalSwinkaran8-Jan-15 10:12 
QuestionWhy is happening this error: Object synchronization method was called from an unsynchronized block of code. ? Pin
FANMixco7-Jan-15 8:38
FANMixco7-Jan-15 8:38 
AnswerRe: Why is happening this error: Object synchronization method was called from an unsynchronized block of code. ? PinPopular
Richard Deeming7-Jan-15 8:57
mveRichard Deeming7-Jan-15 8:57 

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.