private async void EditServiceParameterTextForm_Load(object sender, EventArgs e) { Enabled = false; using (var channel = ChannelManager.CreateChannel()) { try { if (serviceId != Guid.Empty) { service = await taskPool.AddTask(channel.Service.GetService(serviceId)); } ServiceParameterText = serviceParameterTextId != Guid.Empty ? await taskPool.AddTask(channel.Service.GetServiceParameter(serviceParameterTextId)) as ServiceParameterText : new ServiceParameterText() { Service = service, Name = "Новый параметр", MinLength = 1, MaxLength = 30 }; Enabled = true; } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } } }
private async void saveButton_Click(object sender, EventArgs e) { using (var channel = ChannelManager.CreateChannel()) { try { saveButton.Enabled = false; ServiceParameterText = await taskPool.AddTask(channel.Service.EditServiceParameterText(serviceParameterText)); if (Saved != null) { Saved(this, EventArgs.Empty); } } catch (OperationCanceledException) { } catch (CommunicationObjectAbortedException) { } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (FaultException exception) { UIHelper.Warning(exception.Reason.ToString()); } catch (Exception exception) { UIHelper.Warning(exception.Message); } finally { saveButton.Enabled = true; } } }