dotnet / dotnet/winforms

First time set Form.Text in Load event will cause no taskbar icon when program startup without focus

Open
#9,770 8 comments 1 reaction 0 assignees View on GitHub
:beetle: bug
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

### .NET version

.netfx2.0-.net6.0 tested, I believe it's ALL of .net versions.

### Did it work in .NET Framework?

No

### Did it work in any of the earlier releases of .NET Core or .NET 5+?

_No response_

### Issue description

Meet follow conditions, .net winform app will no icon on taskbar:
- Start without focus. for example, mouse clicks on other places during startup.
- App set `Form.Text` is in `Load` event.
- App not set `Form.Text` in `constructor` or `InitializeComponent`.

### Steps to reproduce

[NoTaskbarIconDemo.zip](https://github.com/dotnet/winforms/files/12414867/NoTaskbarIconDemo.zip)
- Compiled `exe` included.
- Note `Text` assignment in Form1.Designer.cs is commented.
- `Thread.Sleep` in `program.cs` is for simulate production programs that need long startup time, so in this time it might happen many thing like lost focus, users usually don't wait only for you.

https://github.com/dotnet/winforms/assets/12094247/793757e0-5fb2-4cf8-845f-b65c612ad197

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.