public void Detach(object parameter)
        {
            ResourceDetailActionEventArgs actionEventArgs = new ResourceDetailActionEventArgs(ResourceDetailActionType.Detach);
            Operation operation = null;

            try { operation = Service.Hosting.VirtualMachine.DetachDisk(this.virtualMachine, this.disk); }
            catch (Exception x)
            {
                actionEventArgs.Resource = this;
                actionEventArgs.Error = true;
                actionEventArgs.ErrorMessage = x.Message;
            }

            if (this.DetailAction != null)
            {
                actionEventArgs.Operation = operation;

                this.DetailAction(this, actionEventArgs);
            }
        }
        private void OnDetailAction(object sender, ResourceDetailActionEventArgs e)
        {
            if (e.Error)
            {
                this.ErrorMessage = e.ErrorMessage;
                this.DisplayError = true;
            }
            else
            {
                if (e.Operation != null)
                {
                    OperationViewModel operationViewModel = new OperationViewModel(e.Operation);

                    operationViewModel.Refreshed += delegate
                    {
                        ResourceViewModel resourceViewModel = (ResourceViewModel)sender;

                        if (operationViewModel.Step == OperationStep.Done)
                        {
                            this.OnOperationCompleted(operationViewModel, resourceViewModel);
                        }
                    };

                    this.OperationsViewModel.OperationViewModelCollection.Add(operationViewModel);
                }
            }
        }