static void Main(string[] args) { DiskInfoClient dic = new DiskInfoClient(); dic.BeginDiskSpaces("d", new AsyncCallback(OnResult), dic); Console.ReadKey(); dic.Close(); }
static void Main(string[] args) { DiskInfoClient dic = new DiskInfoClient(); dic.BeginDiskSpaces("d", new AsyncCallback(OnResult), dic); Console.ReadKey(); dic.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); string freeC = cl.FreeSpace("c"); string totalC = cl.TotalSpace("c"); Console.WriteLine("Info about disk C:\n Total Space:{0}\n Free Space:{1}\n", freeC, totalC); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); string freeC = cl.FreeSpace("c"); string totalC = cl.TotalSpace("c"); Console.WriteLine("Info about disk C:\n Total Space:{0}\n Free Space:{1}\n",freeC, totalC); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); MyDiskInfo disk = cl.DiskSpaces("c"); Print(disk); MyDiskInfo disk2 = cl.DiskSpaces("d","disk"); Print(disk2); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); MyDiskInfo disk = cl.DiskSpaces("c"); Console.WriteLine("Information about disk {0}:", disk.DiskName); Console.WriteLine("\tdisk type : {0}", disk.DiskType); Console.WriteLine("\ttotal space : {0}", disk.TotalSpace); Console.WriteLine("\tfree space {0}:", disk.FreeSpace); Console.WriteLine(); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); MyDiskInfo disk = cl.DiskSpaces("c"); Print(disk); MyDiskInfo disk2 = cl.DiskSpaces("d", "disk"); Print(disk2); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); MyDiskInfo disk = cl.DiskSpaces("c"); Console.WriteLine("Information about disk {0}:", disk.DiskName); Console.WriteLine("\tdisk type : {0}", disk.DiskType); Console.WriteLine("\ttotal space : {0}", disk.TotalSpace); Console.WriteLine("\tfree space {0}:", disk.FreeSpace); Console.WriteLine(); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
public async void GetDiskInfoFromServiceAsync() { //Без прокси /*ChannelFactory<IDiskInfo> TestChannelFactory = new ChannelFactory<IDiskInfo>(new NetHttpBinding(), new EndpointAddress("http://localhost:8080/DiskInfoService/EndPoint_1")); IDiskInfo ChannelToService = TestChannelFactory.CreateChannel();*/ //С прокси DiskInfoClient ClientProxy = new DiskInfoClient(MyResourses.Texts.EndPoint_1); try { ConsoleTextBox.Text = await ClientProxy.GetDriversDataAsync(); ClientProxy.Close(); } catch (FaultException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (CommunicationException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (TimeoutException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } finally { lock (StatusChangeGate) { if (!ShutDown) Application.Current.Dispatcher.Invoke(new Action(() => StatusLabel.Content = MyResourses.Texts.StatusFree)); ClientBusy = false; } } }
public void GetDriversNames() { lock (SafeProgramClosingGate) { //Ниже использован рекомендуемый способ закрытия прокси клиента DiskInfoClient ClientProxy = new DiskInfoClient(MyResourses.Texts.EndPoint_1); try { List<string> CurrentDrivers = ClientProxy.GetDriversNames(); StringBuilder ListOfDrivers = new StringBuilder(); foreach (string DriveName in CurrentDrivers) { ListOfDrivers.Append(DriveName + " "); } Application.Current.Dispatcher.Invoke(new Action(() => DriversNamesLabel.Content = ListOfDrivers)); ClientProxy.Close(); } catch (FaultException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (CommunicationException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (TimeoutException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } finally { lock (StatusChangeGate) { if (!ShutDown) Application.Current.Dispatcher.Invoke(new Action(() => StatusLabel.Content = MyResourses.Texts.StatusFree)); ClientBusy = false; } } } }
public void GetDriveInfoFromService(string DriveName) { lock (SafeProgramClosingGate) { //Ниже использован рекомендуемый способ закрытия прокси клиента DiskInfoClient ClientProxy = new DiskInfoClient(MyResourses.Texts.EndPoint_1); try { MainDriveInfo CurrentDriveInfo = ClientProxy.GetOneDriveData(DriveName); if (CurrentDriveInfo != null) { Application.Current.Dispatcher.Invoke(new Action(() => DriveInfoLabel.Content = CurrentDriveInfo.Name + " " + MyResourses.Texts.Free + " " + CurrentDriveInfo.AvailableSpace + " " + MyResourses.Texts.GigaByte + " " + MyResourses.Texts.From + " " + CurrentDriveInfo.TotalSpace + " " + MyResourses.Texts.GigaByte)); } else { Application.Current.Dispatcher.Invoke(new Action(() => DriveInfoLabel.Content = MyResourses.Texts.CantFindDriveByName)); } ClientProxy.Close(); } catch (FaultException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (CommunicationException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (TimeoutException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } finally { lock (StatusChangeGate) { if (!ShutDown) Application.Current.Dispatcher.Invoke(new Action(() => StatusLabel.Content = MyResourses.Texts.StatusFree)); ClientBusy = false; } } } }