Your best bet would be use a separate thread to do the long process. If you are using .Net 4.0 then you could use Tasks like this:
private void button2_Click(object sender, EventArgs e)
{
pictureBox1.Visible = true;
button2.Enabled = false;
TaskScheduler UISyncContext = TaskScheduler.FromCurrentSynchronizationContext();
Task task1 = Task.Factory.StartNew(() => uploadUsingText()).ContinueWith((t) =>
{
pictureBox1.Visible = false;
button2.Enabled = true;
}, UISyncContext);
}
This assumes that you initially set your picturebox to Visible = false in your designer. I would also suggest you give your control meaningful names. pictureBox1 and button2 are not really a good idea.
According to your comment you are using .Net 3.5. In that case I would simply use a BackGroundWorker to do the long process. Create a BackGroundWorker in your designer and then you could do something like this:
public Form1()
{
InitializeComponent();
button2.Click += new EventHandler(button2_Click);
this.backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
this.backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
}
void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
uploadUsingText();
}
private void button2_Click(object sender, EventArgs e)
{
this.panel1.Enabled = false;
this.pictureBox1.Visible = true;
this.backgroundWorker1.RunWorkerAsync();
}
void uploadUsingText()
{
Thread.Sleep(60000);
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.panel1.Enabled = true;
this.pictureBox1.Visible = false;
}
Hope this helps