Hello,

 

I am using a client written in C#. For the sake of this discussion, imagine the app being discussed as an app just like the Java GUI app that ships with BaseX: You can basically author Xquery snippets and send them for execution by the server.

 

We regularly have queries that tend to run for a long time, and it would be an advantage for the user to be able to cancel these long running jobs, just like he can in the GUI app. However, I am not sure how to do this; I can imagine two solutions:

  1. I see that jobs that are submitted normally to the server end up as jobs, just like the ones that are submitted with jobs:eval(query): I can stop that job with jobs:stop(jobId) on another session if the jobId is known. You would need a separate session that fetches the running jobs and gets the current one (recognizing it by creating a cookie in a comment in the query) with jobs:list-details(), then getting the jobId and then calling jobs:stop(jobId). It is possible I guess, but very heavy handed.
  2. The other option is just as bad: submit the query through jobs:eval(query), getting the jobId and then poll for it to finish; more polling which will not scale with many users and will not provide the quick feedback we want.

 

I see some traces of an eventing mechanism that was deprecated (or at least no longer included in the client). That is what I would ideally have (ignoring bindings etc):

 

Query q = new Query(“1 to 10” , new Guid());

q.Ended += MyTerminationHandler(); // C# syntax for adding an event handler for termination

q.Interrupted += MyInterruptedHandler();

 

await q.execute();

 

// Called when the query has terminated with a result

void MyTerminationHandler(Guid g, string result) { ... update UI … }

 

// Called when the query has terminated with a result

void MyInterruptedHandler (Guid g) { ... update UI … }

 

 

How do I do this without the polling, being able to pass massive results and queries back and forth?

 

Best Regards

 

Peter Villadsen

Principal Architect

Microsoft Business Applications Group