Click here to Skip to main content
15,887,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using FileOpenPicker to select the file for that i am initializing with the mainwindow handle by using this API WinRT.Interop.InitializeWithWindow.Initialize
but after closing the FileOpenPicker the mainwindow got freezes to retrieve the normal state I need to move the mouse in to the tittle bar of my application or taskbar.

What I have tried:

 var parentWindow = FindWindow(null,"MyAppTittle");
 var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.FileTypeFilter.Add(".bmp")
 WinRT.Interop.InitializeWithWindow.Initialize(openPicker, parentWindow); //Initilaize 
StorageFile imageFile = await openPicker.PickSingleFileAsync();
if (imageFile == null) return;
Posted
Updated 6-Apr-23 4:22am
Comments
Member 15627495 6-Apr-23 5:23am    
you have to handle few threads. MTA
the main window thread is too busy, then it freeze.
it's a 'busy state' of your main Windows, not a bug.
Fazil13 6-Apr-23 5:36am    
how to do that can u provide some sample please
Member 15627495 6-Apr-23 6:13am    
threads are 'processing units'
they could be STA or MTA ( Single Thread .. or Mulitple Thread built )

any App is loaded into a Thread.
to empower your Apps, you can use more than one Thread.

Thread can be created , used, and destroy and are dedicated to execute codes aside the Main Thread.
link : https://learn.microsoft.com/en-us/dotnet/api/system.threading.thread?view=net-7.0
Richard MacCutchan 6-Apr-23 10:53am    
Nothing to do with the question. Did you get this answer from ChatGPT?
Member 15627495 6-Apr-23 10:58am    
I wait for your solutions Richard MacCutchan

1 solution

You're mixing Windows RT and WPF. You have a hack that is apparently "just working" (async interop). Stick to what is "typical".

The OpenFileDialog - The complete WPF tutorial[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900