Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 16 of 16 total
Thread Cannot access the ... instance member from within a class method
Wed, Jul 5 2017 12:00 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< I am not sure I understand Matt's notes or Tim's but I will try my best. If I can't figure it out,  I may try timers for now. >>

Please don't use a timer.  Or, if you do, don't tell anyone that you used EWB to build the application Wink

It may *appear* to work, but it isn't actually working and you're just setting yourself up for a bug if you run the same application on a faster machine or a machine with better network bandwidth/connectivity.  Considering that we're talking about an application that runs on many different machines with many different browsers, it will be a miracle if it works correctly 50% of the time without setting the timer value so high as to make the response time unacceptable.

Use an event handler for the TServerRequest.OnComplete event, and handle the completion of the server request properly there.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 6 2017 12:26 PMPermanent Link

Big Al

>>Tim Young [Elevate Software] wrote:

>>Use an event handler for the TServerRequest.OnComplete event, and handle the completion of the server >>request properly there.

I am trying to understand how I could best do what you're asking.

Let's say I'm in my LoginForm and wanting to validate the username/password. I want to use a webservice to do this.

I have a generic webservice that takes 2 parameters, the action and a parameter that I want to use.
It has a Request Complete procedure also.
Both of these are in my MainForm, not the LoginForm.

So in my LoginForm, I can execute the generic webservice that's in my MainForm, and that's it since I can't continue with checking the data until the webservice is done.

So how best to determine that the webservice has completed so I can load and verify the dataset in my LoginForm?

Do I add code to the webservice request complete that's in my MainForm that somehow I can check on my LoginForm??

Or am I just being stupid, and should just add the webservice procedure to my LoginForm???? That means I would have a lot of webservice procedures, but it would totally eliminate the need for any timers.

Hopefully you haven't confused you all, and this makes sense?

Big Al
Thu, Jul 6 2017 12:41 PMPermanent Link

Mark Brooks

Slikware

Avatar

In my apps I have a single API class that I create at startup and then share across whichever form wishes to use it, however I think for a first pass you could simply use a TServerRequest within each form that requires access to your web service. Each from can then handle its own completion events.
Thu, Jul 6 2017 1:02 PMPermanent Link

Big Al

>>Mark Brooks wrote:

>>In my apps I have a single API class that I create at startup and then share across whichever form wishes to use >>it, however I think for a first pass you could simply use a TServerRequest within each form that requires access >>to your web service. Each from can then handle its own completion events.

I tend to agree. That's the direction I will head for now.

Thanks

Big Al
Tue, Jul 11 2017 3:51 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< So how best to determine that the webservice has completed so I can load and verify the dataset in my LoginForm?

Do I add code to the webservice request complete that's in my MainForm that somehow I can check on my LoginForm??

Or am I just being stupid, and should just add the webservice procedure to my LoginForm???? That means I would have a lot of webservice procedures, but it would totally eliminate the need for any timers. >>

In general, you should always opt for the more general approach (put the request in a common unit that is accessible everywhere), especially since it doesn't require that much extra code to handle.

What you're missing here is the concept of registering event handlers (callbacks) and using them to detect when something asynchronous has completed.  An event handler is just a method reference, meaning that you can create event handler types, add event handler properties to your forms, and then call them when needed.

To get a handle on how these work, you're going to need to do some reading, specifically this section of the manual:

https://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Events

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jul 19 2017 11:27 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Check out my post here for more information on how to define/chain event handlers:

https://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&page=1&msg=13222#13222

I think it may help with some of your questions on using event handlers to detect the completion of asynchronous events.

Tim Young
Elevate Software
www.elevatesoft.com
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image