Hello,
For long term processing...
In order for your auxiliary form to continue running Gif during processing you will need to start it in a Thread other than Thread where the processing will be done.
Follow the example of the auxiliary form where your Gif image will be displayed:
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace Connessioni.Elos.DB.Remote.Controls
{
/// <summary>
/// Form padrão para ser exibido quando um processamento longo é iniciado
/// </summary>
public partial class FrWorking : Form
{
/// <summary>
/// Se o form foi iniciado
/// </summary>
public bool Started;
/// <summary>
/// Contrutor
/// </summary>
public FrWorking()
{
InitializeComponent();
}
/// <summary>
/// Exibe o form como dialog
/// </summary>
public void ShowDiag()
{
try
{
Application.DoEvents();
ShowDialog();
}
catch (Exception)
{
//
}
}
/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Form.Shown"/> event.
/// </summary>
/// <param name="e">A <see cref="T:System.EventArgs"/> that contains the event data. </param>
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
Application.DoEvents();
BringToFront();
Started = true;
}
}
}
Now follow the example of how to use this form:
/// <summary>
/// Carrega a.....
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btLoad_MouseUp(object sender, MouseEventArgs e)
{
//Form a ser exibido durante o processamento
var w = new FrWorking();
//Executando o form auxiliar em uma nova System.Threading.Thread
var t = new Thread(w.ShowDiag);
//Iniciando a Thread
t.Start();
//Aguardando até q a Thread seja iniciada
while (!w.Started) { }
//:) Execute seu processamento aqui, e seja feliz....
try
{
//Fechando form auxiliar
t.Abort();
}
catch (Exception)
{
//
}
}
friend it only runs back when the _frmProcessor is closed. to continue running use . show
– Thomas Erich Pimentel
The execution is continuing, thanks for the reply. I would not have thought that this method blocked execution with the main form.
– Ronan Silva
We’re here to help each other. =)
– Thomas Erich Pimentel