tags:

views:

106

answers:

1

I have a method Modify() shown below

            // Convert SortedList of objects 


            if (retval) // 
            {
               // Release the database lock
               Debug.Verbose(func, "Unloc");

The functionality which i want to achieve is if flag RuntimeUp true and m_reconnectInProgress false that means if(RuntimeUp && !m_reconnectInProgress) i have to do the entire procees in the Modify() method otherwise i need to return 'retval' as false .We will get retval from ClientModify(col) method also which is processed by some other side

If i put check if(RuntimeUp && !m_reconnectInProgress) on the very begginning and down side else part returning retval = false is sufficient or is there any other convenient way to do that so that we can avoid bad logic

I did above assumption based on this comment obtained"" There is no need to create the list of modified objects[col.Add(dmo);] if the RuntimeUp == false and m_reconnectInProgress ==true. You can just return false at the top of the Modify method that means You can perform these checks at the beginning of the Modify method rather than waiting until the call to ClientModify ""

A: 

If I understand correctly I'd just add the lines

if(!RuntimeUp || m_reconnectInProgress) 
    return false;

At the very top of the method, which I think is a perfectly acceptable way of avoiding running the method if the application isn't in the correct state for running it right then.

However, the comment bit of your question does not mention that it should check for reconnect in progress, so I'm not sure if you should be doing that?

ho1
peter
i tried if (!RuntimeUp on begginning of try block,,but its not working
peter
@peter: No, I changed around so instead of checking `if it's up and not reconnecting then do the process`, it'll check `if it's down or reconnecting, then exit the method`. Top of method means right after the first `{` (so before the `try`, that if shouldn't be able to throw anyway so you don't need a try around it).
ho1
ho1
Yea above try block it will work and || is working
peter