c# - Delegate section doesn't run on client-side of MMO -


this code here fine, doesn't appear running delegate section. marked isn't working comments:

using unityengine; using system.collections; using ogclient_framework;  [packetopcode(1)] public class packet_01_login : packet  {       public override void decode()      {         bool success = bytebuffer.readboolean ();         if (success)          {             int networkid = bytebuffer.readint();             debug.log ("successful login, network id:" + networkid);          }         else         {              debug.log ("not correct/server down");              int opcode = bytebuffer.readint();              debug.log ("test");             //below section not run, no errors shown, debug log 'test1' not printed debug log above is.             gameclient.singleton.prepare(delegate{                 interfacemanager.singleton.loginmessage(opcode);                 debug.log ("test1");              });          }     } } 

why not work? can fix it?

this code here fine, doesn't appear running delegate section.

that's because code doesn't execute delegate.

this code passes delegate gameclient.singleton.prepare, it's gameclient.singleton.prepare whether , when it executes delegate.

consider following code:

    private delegate void mydelegate();      private void button1_click(object sender, eventargs e)     {         prepare(delegate         {             debug.writeline("test1");         });     }      private void prepare(mydelegate d)     {         debug.writeline("prepare");          //maybe invoke delegate, maybe not yet         //     d.invoke();     } 

when button1_click fires, see "prepare" in debug trace--not "test1", unless uncomment invoke statement.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -