Page 1 of 1

Script user login

Posted: Wed Mar 27, 2019 3:26 am
by Claus Nielsen
Having a problem I'm finding really hard to debug.

In a script module, I'm using Globals.Security.Login() to switch between users and switch to the application default window on successfull login. Sometimes though, I'm getting this exception "The calling thread cannot access this object because a different thread owns it". In Visual Studio it's confirmed that it is that exact line failing.

I do not have any multi threading going on.

Any help would be appreciated. Using iX Developer 2.4 sp1 targeting a PC runtime. Tried multiple machines and they all throw the exception.

Re: Script user login

Posted: Fri May 24, 2019 10:56 am
by Russ C.
If all you're doing is changing screens when a user logs in, I would use the SystemTagCurrentUser (Tags -> Add -> System Tag -> Current User)
add_system_tags.png
add_system_tags.png (11.18 KiB) Viewed 5096 times
system_tag_current_user.png
system_tag_current_user.png (22.43 KiB) Viewed 5096 times
Then use that tag's Value Change event to show the screen:

Code: Select all

		void SystemTagCurrentUser_ValueChange(System.Object sender, Core.Api.DataSource.ValueChangedEventArgs e)
		{
			if(SystemTagCurrentUser.Value.String.Length > 0)
				Main_Logged_In_Screen.Show();
			if(SystemTagCurrentUser.Value.String == "")
				Login_Screen.Show();				
		}