Answer the question
In order to leave comments, you need to log in
Can a Windows Form have a single element on its own thread?
There is a regular form with textboxes and buttons, when the form performs calculations in the corner, the animation element becomes visible, but because of the calculations, the animation slows down and twitches. Is it possible to create a control with animation on its own thread so that the calculations of the main form do not slow down the animation?
I tried to create an animation in the stream, it was created, but it still stuck to the main form and lives in it.
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Thread threadLoadImage = new Thread(new ThreadStart(this.ThreadLoadingImage));
threadLoadImage.Start();
}
private void ThreadLoadingImage()
{
PictureBox LoadingImage2 = new PictureBox
{
Anchor = System.Windows.Forms.AnchorStyles.Bottom,
BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom,
Cursor = System.Windows.Forms.Cursors.WaitCursor,
Image = Resources.progressbar_cat,
Location = new System.Drawing.Point(0, 22),
Name = "LoadingImage2",
Size = new System.Drawing.Size(1165, 154),
SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom,
TabStop = false,
Visible = true,
BackColor = Color.Transparent,
};
Invoke((MethodInvoker)(() => this.Controls.Add(LoadingImage2)));
}
Answer the question
In order to leave comments, you need to log in
The entire UI is processed in the UI thread, complex calculations need to be done in the BackgroundWorker https://docs.microsoft.com/ru-ru/dotnet/api/system...
or async/await + SynchronizationContext.Current.Post
i.e. you need to take out not animation, but calculations
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question