- In the extension bar, click the AdBlock Plus icon
- Click the large blue toggle for this website
- Click refresh
- In the extension bar, click the AdBlock icon
- Under "Pause on this site" click "Always"
- In the extension bar, click on the Adguard icon
- Click on the large green toggle for this website
- In the extension bar, click on the Ad Remover icon
- Click "Disable on This Website"
- In the extension bar, click on the orange lion icon
- Click the toggle on the top right, shifting from "Up" to "Down"
- In the extension bar, click on the Ghostery icon
- Click the "Anti-Tracking" shield so it says "Off"
- Click the "Ad-Blocking" stop sign so it says "Off"
- Refresh the page
- In the extension bar, click on the uBlock Origin icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the uBlock icon
- Click on the big, blue power button
- Refresh the page
- In the extension bar, click on the UltraBlock icon
- Check the "Disable UltraBlock" checkbox
- Please disable your Ad Blocker
- Disable any DNS blocking tools such as AdGuardDNS or NextDNS
- Disable any privacy or tracking protection extensions such as Firefox Enhanced Tracking Protection or DuckDuckGo Privacy.
If the prompt is still appearing, please disable any tools or services you are using that block internet ads (e.g. DNS Servers, tracking protection or privacy extensions).
Question
firey
I have a project that users send data to a server written in C#. The users have the ability to send an action against an object. To reduce DB Traffic, I am using IDistributedCache to hold the instance of the main object, as it also allows for cross-server shared caching.
I am running into an issue with multiple threads where two people send an action to the server. Each thread calls the same function which loads up the instance of the object from the IDistributedCache (using _cache.getAsync(,....)). This results in each thread effectively ending up with it's own instance of the object. The issue is that whatever thread finished last, ends up writing that instance of the object back to the cache, thus losing any changes made in the other thread as the modified object isn't what the current thread has in it's memory.
I was thinking that I could use a standard hashtable/dictionary and just reference the object directly ie: objdict[objid].actions.add(action). That way I have one instance in memory that all threads would have the same state for. However, doing it that way I have no way to support distribution like I do with the IDistributedCache.
I am wondering if anyone has dealt with this, or has any idea of how can I make it so that both threads get the same reference to the object (akin to using the dictionary), but keep it so it can be split across servers (distributed).
Link to comment
https://www.neowin.net/forum/topic/1381045-c-idistributedcache-multi-thread-approach-question/Share on other sites
3 answers to this question
Recommended Posts