+ 1

Loading Animation in c# Console

hi Friends , is there any function in c# wich animate a loading Sequenz ?? If Not is it possible to do it in a tricky way?? IT has to be in the simple console not with graphics and so on. Ive tried it with visual Studio (iam a beginner) .

30th Jul 2018, 8:20 PM
Korhall
Korhall - avatar
7 Réponses
+ 1
Hi Korhall, try to use a timer in combination with a plain text like "Loading " and printed dots ('.'): using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; // mandatory for timer namespace ConsoleApp1 { class Program { static void Main(string[] args) { Console.Write("Loading "); // Create instance of timer ticking every 1000 ms Timer t = new Timer(TimerCallback, null, 0, 1000); // Wait for the user to hit <Enter> Console.ReadLine(); t = null; // Timer destroyed } // callback function for timer, which prints the dots static void TimerCallback(Object o) => Console.Write("."); } }
30th Jul 2018, 9:14 PM
P.W.R.
P.W.R. - avatar
+ 1
wow i will try it . if u could see what i have done to simulate a loading process hahhaha iam happy that my code is private i thank you so much i will try it. sounds nice to me
30th Jul 2018, 10:06 PM
Korhall
Korhall - avatar
+ 1
ich sehe gerade dass du aus Deutschland kommst. Danke auf jeden fall, das sieht vielversprechend aus!
30th Jul 2018, 10:08 PM
Korhall
Korhall - avatar
+ 1
Hi Korhall, please try timer.dispose(); Greetings Peter
31st Jul 2018, 4:23 AM
P.W.R.
P.W.R. - avatar
+ 1
Hi Korhall, sorry, it has to be t.dispose(); example: Console.Write("Loading "); Timer t = new Timer(TimerCallback, null, 0, 1000); // Wait for the user to hit <Enter> Console.ReadLine(); t.Dispose(); Console.WriteLine("Timer disposed!"); Console.ReadLine(); Peter
31st Jul 2018, 9:26 PM
P.W.R.
P.W.R. - avatar
0
yeah it works. But still have 1 problem, The Timer wont end and it will also write Loading infinitely
30th Jul 2018, 10:29 PM
Korhall
Korhall - avatar
0
Thank you peter, but i dont know how to use timer.dispose();
31st Jul 2018, 2:45 PM
Korhall
Korhall - avatar