Recently i worked on integration of sharepoint windows phone. I used web services provided by sharepoint for the communication.
Form there i came to know that windows phone supports only Async calls to the webservices, which start executing remaining line of code and once I get response It will start executing it. But in this case suppose my logic is depends upon response of web service then its not useful for me to call async call of web service. I need to write all logic in openreadcompleted or these kind of events etc.
This does not work in all scenorious so i created a class name CustomTask for communication and the code goes below:
MainClass
{
foreach (Task t in tasks)
{
CustomTask objCustomTask = new CustomTask();
objCustomTask.IsTaskCompleted += new EventHandler<CustomEventArgs>(objCustomTask_IsTaskCompleted);
objCustomTask.sortTasks(t.ID, t);
}
}
public class CustomTask
{
public event System.EventHandler<CustomEventArgs> IsTaskCompleted;
CustomEventArgs objCustomEventArgs = new CustomEventArgs();
WorkflowService.WorkflowSoapClient ws = new WorkflowService.WorkflowSoapClient();
public void sortTasks(String id, Task t)
{
objCustomEventArgs.objTask = t;
ws.CookieContainer = Login.cookieJar;
ws.GetWorkflowDataForItemAsync("TaskName");
ws.GetWorkflowDataForItemCompleted += new EventHandler<WorkflowService.GetWorkflowDataForItemCompletedEventArgs>(ws_GetWorkflowDataForItemCompleted);
}
void ws_GetWorkflowDataForItemCompleted(object sender, WorkflowService.GetWorkflowDataForItemCompletedEventArgs e)
{
objCustomEventArgs.IsPendingTask = false;
XElement objxelement = e.Result;
IEnumerable<XElement> objXElementColl = objxelement.Descendants(XName.Get("ActiveWorkflowsData", Constant.strWorkflowList));
foreach (XElement objXElementWorkflowTemplate in objXElementColl)
{
XElement objXElementWorkflows = objXElementWorkflowTemplate.Element(XName.Get("Workflows", Constant.strWorkflowList));
if (objXElementWorkflows != null && objXElementWorkflows.HasElements == false)
{
objCustomEventArgs.IsPendingTask = true;
}
}
IsTaskCompleted(sender, objCustomEventArgs);
}
public List<Task> GetPendingTask()
{
return null;
}
}
My Work is done bu i have some Questions in my mind:
The method i used will this effect Perfomance of the application?
does Asynchronous calls means that we can not implement 3 tier architecture?
Why Synchronous calls are not supported.