Open oatsoda opened 5 years ago
I have upgraded to CSLA 4.9.0 and still the same issues.
I've also tried changing to using the ClientContext
instead of LocalContext
and this has a different issue - I assume somehow it is not threadsafe as if I add a Guid to the ClientContext
in DataPortal.DataPortalInvoke
then I am seeing it occasionally have the same value in ClientContext
when DataPortal.DataPortalInvokeComplete
fires for different requests.
What I am really after is some way of injecting a token/guid into every request so that I can match it up from the response.
LocalContext
has the limitation that the token/guid is stored locally and relies on the same Thread executing the response.
ClientContext
has the limitation that it is App-wide on the client - rather than per-request.
I could look at overriding SaveAsync
passing the userstate, but this wouldn't cover me for object Fetches (or direct Deletes).
I have a very large, complex app so trying to implement a Synchronisation Context would be very time-consuming and risky (danger of tying up UI thread I suspect).
I take it you are running the data portal in local mode - as in the "server-side" code is actually running on the client device?
Ah, should have said that I am running in 2-Tier mode using WcfPortal on the server (using NetTcpBinding).
Part of the reason for attempting to add the AppInsights tracing is that I am investigating moving to the HttpPortal (WCF NetTcp is restricting the Azure infrastructure I can deploy to) - or even just HttpBinding - but I need to be able to benchmark the changes before I can get go-ahead!
I am looking to add some App Insights tracing to my WinForms client but having problems with async DataPortal calls.
To do this I am using the
DataPortal.DataPortalInvoke
andDataPortal.DataPortalInvokeComplete
events.I add a Guid to the
LocalContext
in the former, so that I can track the response in the latter and record timings.However, when async methods are called, the
LocalContext
has no entry in it - which, based upon this old thread suggests that it is due to theLocalContext
being stored on the Thread - and presumably my response is coming in on a different thread.Things have moved on since this old thread - so I wanted to ask if anyone has any suggestions on how I work around this?
I plan to attempt an upgrade to a newer CSLA version (but I have some technical problems to overcome first). I had hoped that changes in 4.6.600 may have helped - based upon this thread - but no luck.
CSLA version: 4.6.603 OS: Windows Platform: WinForms