Ejemplo n.º 1
0
		/// <summary>
		/// Invokes the specified operation asynchronously.
		/// </summary>
		/// <remarks>
		/// The <cref="AsyncInvocationCompleted"/> event will be fired when the request completes, and the response
		/// will be available from the event args.
		/// </remarks>
		/// <param name="operationName">The name of the operation to invoke.</param>
		/// <param name="requestJsml">The request object, as JSML.</param>
		/// <returns>An invocation ID string.</returns>
		public string InvokeOperationAsync(string operationName, string requestJsml)
		{
			// generate an invocation ID
    		var id = Guid.NewGuid().ToString();

			// invoke operation asynchronously
    		var asyncTask = new AsyncTask();
    		string response = null;
			asyncTask.Run(
				delegate
				{
					response = InvokeHelper(operationName, requestJsml);
				},
				() => OnInvocationCompleted(id, response),
				error => OnInvocationError(id, error));

    		return id;
		}