Background
Break News
How to add local font to Tailwind Css and NextJS? - Tutorial Design Pattern? - Blockchain Technology, How to create own Bitcoin virtual currency - Zustand mordern management state - Design Pattern - Flyweight Pattern? - Docker Full training Topic

[Solved] How to Solve SendMessage Not Responding Issue with System.Threading.Timer

Tuesday, 9 February 2016
|
Read: Completed in minutes

[Solved] How to Solve SendMessage Not Responding Issue with System.Threading.Timer

Happy lunar year to all ^_^

Today topic is show you how to SendMessage to another window will not responding message!

Use System.Threading.Timer in SendMessage Not Responding



On the multiThread, working with process and GUI for users, you can use SendMessage.
At some time, we want to this window send message to another window.
Win32 API SendMessage will be help you easy do it

On some case:
When we run a program: on the task's search, data compression, image compression, etc ..., We can give another Thread running





On C# language, we have two Timer (one is System.Windows.Forms.Timer, and another is System.Threading.Timer)

If you use System.Windows.Forms.Timer, The GUI will be lock all user action, because this is only one Thread working
If you don't want lock user action, you can try to use System.Threading.Timer. The timer running with another Thread. So you not get locked



// Zidane - huuvi168@gmail.com
// DateTime: 2016-02-09

private const uint TIMER_GLOBAL = 500;
private static System.Threading.Timer _timer_Global;   

// Load global Timer          
System.Threading.TimerCallback cb = 
                new System.Threading.TimerCallback(timer_Global_Fn);            
            
// Create the timer. It is autostart, so creating the timer will start it.
_timer_Global = new System.Threading.Timer(cb, null, TIMER_GLOBAL, 1000);


private void timer_Global_Fn(Object obj)
{
     // do something here
     // ...
}

Chinese version


在多重 thread 下, 希望一邊工作, 一邊把工作進度呈現給使用者. 你可以使用 SendMessage.

有的時候, 我們會希望某一個視窗送一個訊息給另一個視窗.
Win32 API SendMessage 可以完成你想要的功能.

最常遇到的狀況是,
當我們在程式中, 進行 資料壓縮, 影像壓縮 或 資料搜尋 等高時間消耗的工作時,
就必須把這些工作, 交給獨立的 thread 來執行.
一般的情況是, 一條 thread 進行使用者介面操作, 另一條 thread 進行高時間消耗的工作.
兩者的通訊, 則可以使用 Message 進行交流.

如果你使用 System.Windows.Forms.Timer 來處理, 則會 lock 住所有使用者的動作.
因為這個 object 是單一執行緒. 這是假的多工.
高時間消耗工作, 會搶去所有的執行時間, 使得你的視窗無法得到任何有關使用者的動作事件.
而且你也無法在視窗上更新進度.

高時間消耗工作, 又要同時顯示進度. ---> 你需要真的多工
使用 System.Threading.Timer 可以建立一條新的 thread,
然而, 如果你需要在一條工作 thread 進行工作進度的視覺呈現, 你可以使用 SendMessage.

Happy new year. Wishes you healthy, happy, successful and lucky ^^

Thank you for reading this post. I hope you found it helpful and easy to follow. If you have any feedback or questions about How to Solve SendMessage Not Responding Issue with System.Threading.Timer , please share them in the comments below. I would love to hear from you and discuss this topic further
✋✋✋✋  Webzone Tech Tips, all things Tech Tips for web development  - I am Zidane, See you next time soon ✋✋✋✋

🙇🏼🙇🏼 We Appreciate Your Comments and Suggestions - Webzone, all things Tech Tips web development
Popular Webzone Tech Tips topic maybe you will be like it - by Webzone Tech Tips - Zidane
As a student, I found Blogspot very useful when I joined in 2014. I have been a developer for years . To give back and share what I learned, I started Webzone, a blog with tech tips. You can also search for tech tips zidane on Google and find my helpful posts. Love you all,

I am glad you visited my blog. I hope you find it useful for learning tech tips and webzone tricks. If you have any technical issues, feel free to browse my posts and see if they can help you solve them. You can also leave a comment or contact me if you need more assistance. Here is my blog address: https://learn-tech-tips.blogspot.com.

My blog where I share my passion for web development, webzone design, and tech tips. You will find tutorials on how to build websites from scratch, using hot trends frameworks like nestjs, nextjs, cakephp, devops, docker, and more. You will also learn how to fix common bugs on development, like a mini stackoverflow. Plus, you will discover how to easily learn programming languages such as PHP (CAKEPHP, LARAVEL), C#, C++, Web(HTML, CSS, javascript), and other useful things like Office (Excel, Photoshop). I hope you enjoy my blog and find it helpful for your projects. :)

Thanks and Best Regards!
Follow me on Tiktok @learntechtips and send me a direct message. I will be happy to chat with you.
Webzone - Zidane (huuvi168@gmail.com)
I'm developer, I like code, I like to learn new technology and want to be friend with people for learn each other
I'm a developer who loves coding, learning new technologies, and making friends with people who share the same passion. I have been a full stack developer since 2015, with more than years of experience in web development.
Copyright @2022(November) Version 1.0.0 - By Webzone, all things Tech Tips for Web Development Zidane
https://learn-tech-tips.blogspot.com