Click here to Skip to main content
15,611,704 members

Comments by Reza jafery (Top 52 by date)

Reza jafery 2-Jan-23 19:05pm View    
Keep an eye on the following image as it closes in a special mode, which takes two seconds:
Click to see
         <Storyboard x:Key="CloseMessageWindow" Storyboard.TargetName="Message_Window" Completed="CloseMessageWindow_Completed">
             <DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[0].Angle" Duration="0:0:2" To="360"/>
             <DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[1].ScaleX" Duration="0:0:2" To="0"/>
             <DoubleAnimation Storyboard.TargetProperty="RenderTransform.Children[1].ScaleY" Duration="0:0:2" To="0"/>
             <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:2.5" To="0"/>

Now, let's imagine that the message window required 2 seconds to load in a specific state. In which case, we have one of these two problems: if we put the message window in Dispatcher.Invoke, our user interface would be frozen for that time period, and if we put it in await Task.Run, we would run into the following error:
Error: The calling thread must be STA, because many UI components require this.
In light of the aforementioned assumption, what solution do you propose?
Reza jafery 16-Dec-22 14:27pm View    
Suppose the loop's range is 0 to 500; are you sure that each command (I mean all commands, methods, etc. in the parallel loop) will be repeated 499 times?
Reza jafery 16-Dec-22 11:05am View    
Even increasing the speed is useless if the parallel loop commands are not repeated for the specified number of times; thus, I try to create an approach that guarantees the loop executes for the specified number of times.
Reza jafery 16-Dec-22 10:33am View    
So you don't think there's any way to solve the following? So, why was the parallel loop created?
• The execution of Parallel.For block codes should be faster than the execution of for block codes.
• Using a flag, a variable, or other mechanisms, ensure that the Parallel.For loop is executed the predefined number of times.
Reza jafery 7-Sep-22 11:11am View    
I thank you all for your recent replies.