- [DEVEXPRESS] Hỗ trợ tìm kiếm highlight không dấu và không khoảng cách trên Gridview Filter
- [C#] Chia sẻ source code phần mềm Image Downloader tải hàng loạt hình ảnh từ danh sách link url
- [C#] Chụp hình và quay video từ camera trên winform
- [C#] Chia sẽ full source code tách file Pdf thành nhiều file với các tùy chọn
- Giới thiệu về Stock Tracker Widget - Công cụ theo dõi cổ phiếu và cảnh báo giá tăng giảm bằng C# và WPF
- [VB.NET] Chia sẻ công cụ nhập số tiền tự động định dạng tiền tệ Việt Nam
- [VB.NET] Hướng dẫn fill dữ liệu từ winform vào Microsoft word
- [VB.NET] Hướng dẫn chọn nhiều dòng trên Datagridview
- Hướng Dẫn Đăng Nhập Nhiều Tài Khoản Zalo Trên Máy Tính Cực Kỳ Đơn Giản
- [C#] Chia sẻ source code phần mềm đếm số trang tập tin file PDF
- [C#] Cách Sử Dụng DeviceId trong C# Để Tạo Khóa Cho Ứng Dụng
- [SQLSERVER] Loại bỏ Restricted User trên database MSSQL
- [C#] Hướng dẫn tạo mã QRcode Style trên winform
- [C#] Hướng dẫn sử dụng temp mail service api trên winform
- [C#] Hướng dẫn tạo mã thanh toán VietQR Pay không sử dụng API trên winform
- [C#] Hướng Dẫn Tạo Windows Service Đơn Giản Bằng Topshelf
- [C#] Chia sẻ source code đọc dữ liệu từ Google Sheet trên winform
- [C#] Chia sẻ source code tạo mã QR MOMO đa năng Winform
- [C#] Chia sẻ source code phần mềm lên lịch tự động chạy ứng dụng Scheduler Task Winform
- [C#] Hướng dẫn download file từ Minio Server Winform
[C#] Tạo hiệu ứng Spinner Animation trên Console App
Xin chào các bạn, bài viết hôm nay mình tiếp tục hướng dẫn các bạn các đoạn source code tạo spinner trên App console C#.
[C#] How to make Spinner Animtion Console App
Khi các bạn viết ứng dụng, đến đoạn xử lý đoạn code cần nhiều thời gian để xử lý.
Để cho người dùng biết là phần mềm đang xử lý dữ liệu, chứ không phải bị treo, thì mình sẽ show các loading spinner để người dùng có thể biết là ứng dụng đang chạy.
1. Xuất process bar trên Console

 class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.ReadKey();
            ShowSimplePercentage();
            Console.ReadKey();
        }
        static void ShowSimplePercentage()
        {
            for (int i = 0; i <= 100; i++)
            {
                Console.Write($"\rProgress: {i}%   ");
                Thread.Sleep(25);
            }
            Console.Write("\rDone!          ");
        }
    }2. Tạo một spinner xoay xoay

static void ShowSpinner()
    {
        var counter = 0;
        for (int i = 0; i < 50; i++)
        {
            switch (counter % 4)
            {
                case 0: Console.Write("/"); break;
                case 1: Console.Write("-"); break;
                case 2: Console.Write("\\"); break;
                case 3: Console.Write("|"); break;
            }
            Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
            counter++;
            Thread.Sleep(100);
        }
    }3. Tạo hiệu ứng cái chuông

static void MultiLineAnimation()
    {
        var counter = 0;
        for (int i = 0; i < 30; i++)
        {
            Console.Clear();
            switch (counter % 4)
            {
                case 0: {
                        Console.WriteLine("╔════╤╤╤╤════╗");
                        Console.WriteLine("║    │││ \\   ║");
                        Console.WriteLine("║    │││  O  ║");
                        Console.WriteLine("║    OOO     ║");
                        break;
                    };
                case 1:
                    {
                        Console.WriteLine("╔════╤╤╤╤════╗");
                        Console.WriteLine("║    ││││    ║");
                        Console.WriteLine("║    ││││    ║");
                        Console.WriteLine("║    OOOO    ║");
                        break;
                    };
                case 2:
                    {
                        Console.WriteLine("╔════╤╤╤╤════╗");
                        Console.WriteLine("║   / │││    ║");
                        Console.WriteLine("║  O  │││    ║");
                        Console.WriteLine("║     OOO    ║");
                        break;
                    };
                case 3:
                    {
                        Console.WriteLine("╔════╤╤╤╤════╗");
                        Console.WriteLine("║    ││││    ║");
                        Console.WriteLine("║    ││││    ║");
                        Console.WriteLine("║    OOOO    ║");
                        break;
                    };
            }
                
            counter++;
            Thread.Sleep(200);
        }
    }4. Xuất màu sắc ra màn hình Console, bạn bạn có thể sử dụng thư viện Colorful.Console để xuất màu ra console một cách dễ dàng
 
 
Các bạn cài đặt Colorful từ nuget:
NuGet\Install-Package Colorful.Console -Version 1.2.15Sử dụng để xuất màu chữ ra màn hình:
using Console = Colorful.Console;
namespace ConsoleAppMagic
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to, laptrinhvb.net");
            Console.WriteLine("This is an error!", Color.Red);
            Console.ReadKey();
        }
    }
}5. Tạo một spin con tàu đang chạy

Source code C#:
static void ColorfulAnimation()
    {
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 30; j++)
            {
                Console.Clear();
                // steam
                Console.Write("       . . . . o o o o o o", Color.LightGray);
                for (int s = 0; s < j / 2; s++)
                {
                    Console.Write(" o", Color.LightGray);
                }
                Console.WriteLine();
                var margin = "".PadLeft(j);
                Console.WriteLine(margin + "                _____      o", Color.LightGray);
                Console.WriteLine(margin + "       ____====  ]OO|_n_n__][.", Color.DeepSkyBlue);
                Console.WriteLine(margin + "      [________]_|__|________)< ", Color.DeepSkyBlue);
                Console.WriteLine(margin + "       oo    oo  'oo OOOO-| oo\\_", Color.Blue);
                Console.WriteLine("   +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+", Color.Silver);
                Thread.Sleep(200);
            }
        }
    }Thanks for watching!

![[C#] Tạo hiệu ứng Spinner Animation trên Console App](https://laptrinhvb.net/uploads/users/9a8cb514e4428e85fb4ca07588e9103f.png)

![[C#] Hướng dẫn sử dụng Try Catch xử lý ngoại lệ trong winform](https://laptrinhvb.net/uploads/source/csharp/insert_text_position_csharp_thumb.jpg)
![[C#] Kiểm tra máy tính có cài đặt phần mềm diệt virus nào không?](https://laptrinhvb.net/uploads/source/csharp/detect_antivirus.jpg)
![[C#] Hướng dẫn fix lỗi hiển thị UTF-8 khi sử dụng WebClient Download String](https://laptrinhvb.net/uploads/source/new_image_baiviet/web_client_download_string.png)
![[C#] Hướng dẫn xuất danh sách hình ảnh nhân viên ra file Excel](https://laptrinhvb.net/uploads/source/web/image_excel_thumb.png)
![[C#] Chia sẽ source code mã đi tuần bằng giao diện Winform](https://laptrinhvb.net/uploads/source/vbnet/ma_di_tuan_csharp.png)
![[C#] Hướng dẫn sử dụng Task Dialog trên NET 5](https://laptrinhvb.net/uploads/source/vbnet/task_dialog_net_5.jpg)
![[C#] Giới thiệu và tìm hiểu những tính năng mới của C# 7.0 trong Visual Studio 2017](https://laptrinhvb.net/uploads/source/image_baiviet/00be3133b47e15513e7c8bd46c8030eb.png)
![[C#] Hướng dẫn sử dụng từ khóa Params để truyền nhiều tham số vào hàm](https://laptrinhvb.net/uploads/source/csharp/params_csharp.png)
![[C#] Lập trình thêm, xóa, sửa, tìm kiếm với Sqlite in C#](https://laptrinhvb.net/uploads/source/image_baiviet/5fed6966f58434819dead34ae8ea9db3.png)
![[C#] Chia sẻ SDK lập trình với máy chấm công Aikyo](https://laptrinhvb.net/uploads/source/DATABASE/aikyo_sdk.jpg)
![[C#] Custom TextBox với Border Winform](https://laptrinhvb.net/uploads/source/csharp/custom_textbox_thumb.png)
![[C#] Hướng dẫn Scan file hình ảnh trên máy scanner sử dụng WIA API](https://laptrinhvb.net/uploads/source/image_baiviet/c09991bd71d43786d784443b00e449b2.jpg)
![[C# - VB.NET] Hướng dẫn sử dụng Bing Translator API dịch các tiếng việt sang tiếng anh](https://laptrinhvb.net/uploads/source/image_baiviet/86527fd8629a528ede94e9c9ead7ce6b.jpg)
![[C#] Hướng dẫn sử dụng thư viện AutoITx lấy id và password Ultraviewer trên winform](https://laptrinhvb.net/uploads/source/auto_it_thumb.png)
![[C#] Hiển thị cửa sổ user consent trên winform NET Core 6](https://laptrinhvb.net/uploads/source/new_image_baiviet/user_consent_csharp.gif)
![[C#] Sử dụng Task.WhenAny kiểm soát các Task thực hiện](https://laptrinhvb.net/uploads/source/csharp/datatable_trigger_thumb.png)

![[C#] Hướng dẫn tạo Dynamic Control Runtime để hiển thị danh bạ](https://laptrinhvb.net/uploads/source/csharp/dynamic_control_csharp_thumb.jpg)
![[C#] Hướng dẫn upload file, hình ảnh từ Winform lên server API ASP.NET Core](https://laptrinhvb.net/uploads/source/new_image_baiviet/upload_file_asp_api.png)
![[C#] Tìm kiếm file trùng nhau trong cùng thư mục lập trình Winform](https://laptrinhvb.net/uploads/source/csharp/duplicate_file_thumb.png)
![[C#] Hướng dẫn sử dụng công cụ Clean Code trên Visual Studio](https://laptrinhvb.net/uploads/source/new_image_baiviet/clean_code_thumb.png)
![[C#] Hướng dẫn mã hóa và giải mã file Text trong lập trình csharp](https://laptrinhvb.net/uploads/source/image_baiviet/fa0a3e547c910fdbf64270bc50a8d148.jpg)
![[C#] Hướng dẫn chuyển đổi convert file Excel sang định dạng XML](https://laptrinhvb.net/uploads/source/image_baiviet/262b0e8ec4a7722bcf55dd4fd5690e59.jpg)
![[C#] Hướng dẫn tạo Form đăng ký, đăng nhập thêm xóa sửa CRUD sử dụng Database FireBase Realtime](https://laptrinhvb.net/uploads/source/csharp/fire_base_thumb.jpg)
