Script user login

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
Claus Nielsen
Posts: 18
Joined: Sun May 31, 2015 2:38 am

Script user login

Post 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.

User avatar
Russ C.
Posts: 213
Joined: Thu Nov 16, 2017 3:32 pm
Contact:

Re: Script user login

Post 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 5090 times
system_tag_current_user.png
system_tag_current_user.png (22.43 KiB) Viewed 5090 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();				
		}
Best regards,

Russ
(801) 708-6690
Technical Support
Contact Us

Beijer Electronics AB
http://www.beijerelectronics.us

Post Reply