I have a form with animation which i show while doing some requests for other forms. I was doing some research how to show this animated form on requests and come up with doing this:
public partial class ProcessingForm : Form
{
private static Thread processingFormThread;
public ProcessingForm()
{
InitializeComponent();
}
public void StartThreadOnProcessingForm()
{
processingFormThread = new Thread(() => { new ProcessingForm().ShowDialog(); });
processingFormThread.Start();
}
public void CloseThreadOnProcessingForm()
{
processingFormThread.Abort();
}
}
and now when i need use the form i do it like this:
public void Foo()
{
ProcessingForm pf = new ProcessingForm();
pf.StartThreadOnProcessingForm();
// some request/data actions
Form requestForm;
if (requestdata!= null)
{
requestForm = new requestForm(data);
pf.CloseThreadOnProcessingForm();
requestForm.Show();
requestForm.SetDataForForm(requestdata);
}
}
This seamed like a pretty simple solution, but i haven't seen anything like it while researching,so it feels like I'm doing something wrong. My question is there a better way to do a simple thing like this?