-
[WPF] LoadingDecorator time increaseC#/WPF 2025. 9. 18. 11:27
int counter = 0; string originContent = string.Empty; void SetLoadingIndicator(bool isLoading = false, string loadingContent = "", SplashScreenLock loadingOwnerLock = SplashScreenLock.LoadingContent) { counter = 0; //LoadingContent = loadingContent; originContent = loadingContent; LoadingOwnerLock = loadingOwnerLock; IsLoading = isLoading; var timer = new System.Timers.Timer(1000); // 1000 milliseconds = 1 second timer.Elapsed += OnTimedEvent!; timer.AutoReset = true; timer.Enabled = IsLoading; } void OnTimedEvent(Object source, ElapsedEventArgs e) { var timer = source as System.Timers.Timer; if (timer is not null) timer.Enabled = IsLoading; counter++; LoadingContent = $"{originContent} {counter}s"; }
# google AI
using System; using System.Timers; public class TimerExample { private static int counter = 0; private static Timer aTimer; public static void Main(string[] args) { aTimer = new Timer(1000); // 1000 milliseconds = 1 second aTimer.Elapsed += OnTimedEvent; aTimer.AutoReset = true; // Repeat the event aTimer.Enabled = true; // Start the timer Console.WriteLine("Press Enter to exit."); Console.ReadLine(); } private static void OnTimedEvent(Object source, ElapsedEventArgs e) { counter++; Console.WriteLine($"Counter: {counter} at {e.SignalTime}"); } }
728x90'C# > WPF' 카테고리의 다른 글
[WPF] TextBlock ( Binding + Text) (0) 2025.10.16 [WPF] AssemblySearchPaths (0) 2025.10.15 [WPF] .NET SDK 프로젝트에서 출력 관리 (0) 2025.09.17 [WPF] Theme image dark , light convert (0) 2025.08.26 [WPF] Text delete button, Tags, Token (0) 2025.08.25 댓글