简体   繁体   English

C#同时调用具有不同值的同一函数

[英]C# Call the same function with different values at the same time

I have a function that changes the text in a label for another one, showing the text transition effect. 我有一个功能,可以将标签中的文本更改为另一个,以显示文本过渡效果。 Imagine that I have 4 labels with texts, and I want to replace their texts with another different ones, showing the same effect but for the 4 labels at the same time, is there any way to do that? 想象一下,我有4个带有文本的标签,并且我想用另一个不同的文本替换它们的文本,显示出相同的效果,但是同时对4个标签,有什么办法可以做到这一点? Call the same function with different values at the same time. 同时调用具有不同值的相同函数。

Thanks in >> 谢谢>>

I would recommend using double-buffering to achieve this effect. 我建议使用双缓冲来达到这种效果。 You update the labels, and then use double-buffering to show the completed form. 您更新标签,然后使用双缓冲来显示完成的表单。 There are plenty of articles on enabling this for WinForms apps, and the concept is applicable to most UI platforms. 关于为WinForms应用启用此功能的文章很多,该概念适用于大多数UI平台。

Windows UI (for WinForms at least) doesn't like to be updated from multiple threads, so I wouldn't bother trying to pursue that (unless you require a lot of background computation to get the new values) Windows UI(至少适用于WinForms)不喜欢从多个线程进行更新,因此我不会费心尝试这种方法(除非您需要大量后台计算才能获取新值)

You can modify your function to change all labels at once. 您可以修改功能以一次更改所有标签。 Something like this: 像这样:

Foreach EffectStep
    Foreach Label
      do some job

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# 存放不同的子类同时调用 - C# store different child classes and call them at same time C#将相同的函数应用于不同的变量 - C# Applying same function to different variables C# 调用具有不同类型的相同扩展函​​数作为参数(也许是委托?) - C# call same extended function with different type as parameter (maybe delegates ?) 如何使用相同的参数调用在C#中定义的函数,返回类型和相同的名称,但在不同的情况下调用VB.NET项目 - How to call a function defined in C# with same params,return type and same name but in different case from a VB.NET project 与C#中的C ++中相同的公式获得不同的值 - Getting Different Values for the same formula in C++ Than in C# 不同线程中同一类的父线程中的C#调用方法 - C# Call method in parent thread in same class in different thread Unity 3D c#2个不同的循环要同时运行 - Unity 3D c# 2 different loops to be run at the same time C#MVC3 Web应用程序中同时存在不同的线程 - Different Thread at same time in C# MVC3 Web Application C#:使用不同的键同时移动两个矩形 - C#: Moving Two Rectangles At The Same Time With Different Keys C#音频 - 如何伸展时间(不同速度,相同音高) - C# Audio - How to time stretch (different tempo, same pitch)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM