From 9f562be5639ba354f1e621fc4c70b34d4af32502 Mon Sep 17 00:00:00 2001 From: Tony Roberts Date: Mon, 4 Apr 2016 16:21:24 +0100 Subject: [PATCH] Start the wordpad demo in an STA thread. This fixes the problem with the open and save dialogs freezing the application. --- demo/wordpad.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/demo/wordpad.py b/demo/wordpad.py index ed51d1122..ed76a6ee8 100644 --- a/demo/wordpad.py +++ b/demo/wordpad.py @@ -9,6 +9,7 @@ import clr import System.Windows.Forms as WinForms +from System.Threading import Thread, ThreadStart, ApartmentState from System.Drawing import Color, Size, Point from System.Text import Encoding from System.IO import File @@ -420,12 +421,19 @@ def OnClickClose(self, sender, args): self.Close() - -def main(): +def app_thread(): app = Wordpad() WinForms.Application.Run(app) app.Dispose() + +def main(): + thread = Thread(ThreadStart(app_thread)) + thread.SetApartmentState(ApartmentState.STA) + thread.Start() + thread.Join() + + if __name__ == '__main__': main()