|
using System;
using System.Threading;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Common;
namespace SQLiteTurbo
{
public partial class HttpPostSenderDialog : Form
{
public HttpPostSenderDialog()
{
InitializeComponent();
}
public void Prepare(PostSubmitter ps)
{
_postSubmitter = ps;
}
public Exception Error
{
get { return _error; }
}
private void btnCancel_Click(object sender, EventArgs e)
{
_postSubmitter.CancelPost();
}
private void HttpPostSenderDialog_FormClosing(object sender, FormClosingEventArgs e)
{
if (!_exit)
{
_postSubmitter.CancelPost();
e.Cancel = true;
}
}
private void HttpPostSenderDialog_Shown(object sender, EventArgs e)
{
WaitCallback wc = delegate
{
bool cancelled = false;
_error = null;
try
{
_postSubmitter.Post();
}
catch (UserCancellationException uce)
{
cancelled = true;
}
catch (Exception ex)
{
_error = ex;
} // catch
try
{
_exit = true;
if (cancelled)
Invoke(new MethodInvoker(delegate { this.DialogResult = DialogResult.Cancel; }));
else
Invoke(new MethodInvoker(delegate { this.DialogResult = DialogResult.OK; }));
}
catch (ObjectDisposedException ode)
{
// Ignore
} // catch
};
ThreadPool.QueueUserWorkItem(wc);
}
private PostSubmitter _postSubmitter;
private Exception _error;
private bool _exit;
}
}
|
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.
My name is Liron Levi and I'm developing software for fun & profit for 15 years already.