c# - await for another method -
i think need async await program can't figure out how it. getdata method need send request socket, , socket data same method. need pass data somehow onreceive initial getdata method. possible implement await async tasks here? here simplified scheme: asynccallback m_pfnlookupcallback; socket m_sock; public void getdata() { string data; if (condition) data = getdatafromcache(); else data = getdatafromnet(); /// !need await socket data here //will process data here. } public string getdatafromnet() { m_sock.send(szcommand, ibytestosend, socketflags.none); waitfordata("s1"); } public void waitfordata(string ssocketname) { m_pfnlookupcallback = new asynccallback(onreceive); m_sock.beginreceive(m_szlookupsocketbuffer, 0, m_szlookupsocketbuffer.length, socketflags.none, m_pfnlookupcallback, ssocketname); } private void onreceive(iasyncresult asyn) {...