Ejemplo n.º 1
0
        private void ProcessFetchXmlQuery(string query)
        {
            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Fetching data...",
                AsyncArgument = query,
                IsCancelable  = true,

                Work = (bw, e) =>
                {
                    var action             = new FetchXmlAction(Service);
                    action.MessageChanged += delegate(object sender, EventArgs eventArgs)
                    {
                        if (SendMessageToStatusBar != null)
                        {
                            SendMessageToStatusBar(this, new StatusBarMessageEventArgs(
                                                       ((FetchXmlAction)sender).Message));
                        }
                    };
                    action.RunFetchXmlQuery(e.Argument.ToString());
                    e.Result = action;
                },
                PostWorkCallBack = e =>
                {
                    if (e.Error == null)
                    {
                        ProcessResponse((FetchXmlAction)e.Result);
                    }
                    else
                    {
                        MessageBox.Show(this, "An error occured: " + e.Error.Message, "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
            });
        }