Help with explanation

青春壹個敷衍的年華 提交于 2019-12-12 05:25:44

问题


I have some codes that i find very hard to understand. Can someone help me break it down line by line?

Service1Client client = new Service1Client();
            client.getPrimaryListCompleted += new EventHandler<getPrimaryListCompletedEventArgs>(AddPrimaryMarkerGraphics);
            client.getPrimaryListAsync();

回答1:


The first line creates an instance of the class Service1Client.

The second line hooks up an event handler for the event getPrimaryListCompleted.

the third line starts an asynchronous request. When there is a response, the getPrimaryListCompleted will be triggered so that the event handler can use the response.




回答2:


  1. Create a new ServiceClient called client.
  2. Add an event handler to client so that when Primary List Function is completed the function AddPrimaryMarkerGraphics is automatically called.
  3. Call the client function getPrimaryListAsync() (Async means that this function will be executed asynchronously ie: on another thread)



回答3:


This Service1Client client = new Service1Client(); creates a new object of type Service1Client() which presumably is a client for calling a WCF service.

Then is attaches an event handler which will get called when the client raises the specified event.

The last line starts an asynchroneous service call (means its running in the background on a separate thread). Once that call has completed it probably raises the getPrimaryListCompleted event so the event handler will be called.



来源:https://stackoverflow.com/questions/5974789/help-with-explanation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!