Terminal.Gui: The application freezes while resizing the terminal on MacOS

Describe the bug The whole app freeze If I resize the terminal while Application fetching the current time from internet.

To Reproduce https://www.toptal.com/developers/hastebin/iruwokoxuw.csharp

Desktop:

  • MacOS

Additional context I don’t know if it’s a bug or I’m doing something wrong. But the same issue you will get in Threading scenario from UICatalog if you run few tasks and start playing with terminal size by mouse.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 20

Commits related to this issue

Most upvoted comments

@tig Sorry for the confusion. It’s fixed now in develop.

You need to update the TextField like this. Here you don’t need to call Application.MainLoop.Invoke because the AddTimeout already handles that. You also don’t need to call SetNeedsDisplay because the Text property already do that.

		static Func<MainLoop, bool> fetchTime = (loop) => {
			UpdateTimeAsync ();
			MainField.Text = Clock.unixtime.ToString ();
			//MainField.SetNeedsDisplay ();

			return true;
		};

I appreciate your recent fix @BDisp but as you can see in the code I’m not trying to update the TextField in any way. But application still will freeze because of UpdateTimeAsync()

I can confirm that your fix is working with threading scenario from UICatalog but not fixes issue what you can see below.

When you replace TextField with Label, there is no issue with resizing & UpdateTimeAsync method fire every 500 ms.

Code https://hastebin.com/share/ucehihumoy.csharp

My mistake, I added the reference to the wrong project. I apologize for the misunderstanding. Recent commit fixes the problem.

https://github.com/gui-cs/Terminal.Gui/assets/76921244/83709188-cfbd-4cad-8454-f23df89be2ce