Desktop project with Page as startup for login problem

Answered
0
0

Hey

I did the following scenario:

  1. Create a new solution for VB.NET with a Wisej.Desktop template
  2. I created a Page called login (with some logic)
  3. I changed the Program.vb, so that instead of “Application.Desktop = new Desktop” to “Applicatio.MainPage = New Login”
  4. When the login is was successful, then I try to do: “Application.Desktop = New Desktop”

But nothing happens, the Login is still visible.

I also tried to Dispose the MainPage and Desktop.Show.

But nothing brings the desktop “in front”. Could you please give me advise, how to handle this correct.

THX Harald

  • You must to post comments
Best Answer
0
0

The code you attached is wrong and it causes a NullReferenceException.

It uses an Async method handler and starts another thread in there with Awai, which starts another thread losing the context a second time! Async methods are executed  in a different thread which has no knowledge of the context. This is not a Wisej issue, the same happens with any web framework when using async handlers. The exception is shown in Visual Studio. Cannot be show on the browser because the new thread is out of context.

There is no reason to use async handlers. But if you really want to, simply pass a reference to the Login method :AddHandler Button1.Click, Sub() locMyMVVM.Login(Me) and in Public Async Sub Login(dialog As Wisej.Web.Form) call dialog.Close().

Also the sample is not using a Page, which is OK. See my attached sample for a different approach.

See also: https://wisej.com/docs/html/BackgroundTasks.htm

 

Attachment
  • You must to post comments
0
0

THX – I will change my code.

 

  • You must to post comments
0
0

Hey

I changed the design, as you told me.

But, I still face issues, when I try to get the Application.OpenForms, within an async routine.

I attach a project, where it can be reproduced.

When you uncomment the Task.Run and don’t use the async word, then everything works as expected.

The problem is, that I use async/await for all of my database queries and therefore I will need it.

THX and I hope a solution can be found

Attachment
  • You must to post comments
0
0

Hi Harald,

In https://github.com/iceteagroup/wisej-examples there is a collection of samples. The UIContainers sample shows the behaviour of different types of applications: Window only, Page+Window and Desktop+Window. Please note that Window is another name for Form.

I’m afraid there isn’t a mixed Desktop/Page application example since Desktop and Page take over the full browser area so one control would hide the other.

If the UIContainers sample doesn’t help, please attach a sample.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.