The essence of the problem: to write a program that, when you press the left arrow on the keyboard, creates a pop-up tooltip with a growing numerical sequence (1 .... 50000) in the place pointed by the cursor. The main condition is the creation of a thread for each pop-up prompt that will process this hint.
The problem itself is that the objects of the Popup class are not displayed in the window, although the threads are executed. If anyone can point out errors or suggest a literature / source on this topic, I would be very grateful.
Code example:
//ΠΠΈΡΡ, Π² ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΠΎ Π½Π°Π΄ΠΎΠ±Π½ΠΎΡΡΠΈ Π΄ΠΎΠ±Π°Π²Π»ΡΡΡΡΡ ΠΏΠΎΡΠΎΠΊΠΈ List < Thread > MyThreads = new List < Thread > (); public void StartPopThread(object obj) { Popup temp = new Popup(); ParamsOfPop FromMain = new ParamsOfPop(); FromMain = (ParamsOfPop) obj; TextBlock txt = new TextBlock(); txt.Background = Brushes.Black; txt.Text = "0"; temp.Child = txt; temp.IsOpen = true; while (FromMain.currenValue < 50000) { temp.Child = txt; txt.Text = FromMain.currentValue.ToString(); FromMain.currentValue++; temp.HorizontalOffset = FromMain.x + FromMain.Left; temp.VerticalOffset = FromMain.y + FromMain.Top; Thread.Sleep(1000); } } private void Window_KeyDown(object sender, KeyEventArgs e) { Point MousPos = Mouse.GetPosition(null); //ΡΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΏΠΎΡΠΎΠΊΠ° ΠΏΠΎ Π½Π°ΠΆΠ°ΡΠΈΡ Π»Π΅Π²ΠΎΠΉ ΠΊΠ»Π°Π²ΠΈΡΠΈ if (e.Key == Key.Left) { MyThreads.Add(new Thread(new ParameterizedThreadStart(StartPopThread))); double a = MousPos.X; double b = MousPos.Y; ParamsOfPop Send = new ParamsOfPop(a, b, this.Top, this.Left); MyThreads[MyThreads.Count - 1].SetApartmentState(ApartmentState.STA); MyThreads[MyThreads.Count - 1].Start(Send); } } class ParamsOfPop { public double x; public double y; public double Top; public double Left; public UInt32 currentValue = 0; public ParamsOfPop() { x = 0; y = 0; } public ParamsOfPop(double a, double b, double c, double d) { this.x = a; this.y = b; this.Top = c; this.Left = d; } } StartPopThread is a function on the basis of which a thread is created to process the Popup object. class ParamsOfPop is a class that passes cursor parameters to a stream.
IsOpen? Show this part, itβs important, I think. - VladD