Unable to register event

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
pringtef
Posts: 45
Joined: Tue Feb 14, 2012 11:23 pm

Unable to register event

Post by pringtef » Mon May 14, 2012 8:56 pm

OS : Win7 x64 (SP1)
PrimalStudio Version : 3.0.3.0
Powershell v2

I'm struggling to find a way within the PrimalStudio 2012 interface to properly register an event in a project so that i can process its eventargs.
Code for registration is below

$webclient = New-Object System.Net.WebClient
Register-ObjectEvent $webclient DownloadProgressChanged -SourceIdentifier WebClient.DownloadProgressChanged

I've tried the above in Globals.ps1, Startup.pfs, and MainForm.pff without success, whenever i try a :-
get-event -SourceIdentifier WebClient.DownloadProgressChanged

I get ERROR: Get-Event : Event with source identifier 'WebClient.DownloadProgressChanged' does not exist.


So far the only way i've found out to get round this to manually edit the ps1 file that is generated by PrimalStudio 2012 (via Export), and enter the registration code code in the #region Import Assemblies section of the file. If i do that, i can then access the event from anywhere in my script. This is a bit inconvenient though.

Is there a way for me to do this within PrimalStudio?

thanks,

tim
pringtef2012-05-15 03:58:18

User avatar
davidc
Posts: 5913
Joined: Thu Aug 18, 2011 4:56 am

Unable to register event

Post by davidc » Tue May 15, 2012 4:00 am

Register-ObjectEvent may not trigger while running a Form. Please try the following instead: $webclient.add_DownloadProgressChanged($scriptBlock)David
David
SAPIEN Technologies, Inc.

User avatar
pringtef
Posts: 45
Joined: Tue Feb 14, 2012 11:23 pm

Unable to register event

Post by pringtef » Fri May 18, 2012 3:10 am

Thanks David, will try this.

User avatar
pringtef
Posts: 45
Joined: Tue Feb 14, 2012 11:23 pm

Unable to register event

Post by pringtef » Fri May 18, 2012 9:15 pm

Works great, and allows me to access all the form objects as well. thanks.