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 LICENSE NUMBERS, ACTIVATION 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.
This topic is 11 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
pringtef
Posts: 45
Last visit: Mon Sep 23, 2019 11:00 am

Unable to register event

Post by pringtef »

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
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Unable to register event

Post by davidc »

Register-ObjectEvent may not trigger while running a Form. Please try the following instead: $webclient.add_DownloadProgressChanged($scriptBlock)David
David
SAPIEN Technologies, Inc.
pringtef
Posts: 45
Last visit: Mon Sep 23, 2019 11:00 am

Unable to register event

Post by pringtef »

Thanks David, will try this.
pringtef
Posts: 45
Last visit: Mon Sep 23, 2019 11:00 am

Unable to register event

Post by pringtef »

Works great, and allows me to access all the form objects as well. thanks.
This topic is 11 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.