using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Windows.Forms; using VsspChat.Properties; using VSSProtocol.Users; using System.Threading; namespace VsspChat.Gui { public partial class WaitForDialogBox : Form { private VsspClient client = null; private VsspServer server; public WaitForDialogBox() { InitializeComponent(); } private void WaitForDialogBox_Load(object sender, EventArgs e) { btnCancel.Enabled = true; backgroundWorker.RunWorkerAsync(); } private VsspClient createServerAndWait() { X509Certificate2 certificate = new X509Certificate2(Settings.Default.Certificate, Settings.Default.CertificatePassword); server = new VsspServer(Settings.Default.Port, certificate); VsspClient localClient = null; try { localClient = server.Accept(); } catch (Exception) { // Ignore } return localClient; } private void btnCancel_Click(object sender, EventArgs e) { server.Stop(); } public VsspClient Client { get { return client; } } private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { e.Result = createServerAndWait(); } private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show(e.Error.Message); DialogResult = DialogResult.Cancel; } else if (e.Result == null) { DialogResult = DialogResult.Cancel; } else { DialogResult = DialogResult.OK; client = (VsspClient)e.Result; } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)