c# - Not Getting Updated data when using threading -


in program there 2 method 1 start processing , second end processing.

public void startprocessing() {     thread.sleep(30000)     bool isactive = _repository.findby(s=>s.uid == 1).isactive  //linq query  }  public void endprocessing()     {     //update data } 

so when call startprocessing() method wait 30 second , after 30 sec returns data sql. problem when updating data before 30 second, it's not returning me updated data. please give me solution of this.

1)don't reuse context (i assume use ef) in many threads.create new context/repository in each thread
2)don't use threads,use tasks (task parallel library )

i guess findby checks loaded items first,that's why "old" data.
if follow "1" problem solved.
if not,you don't update user....


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -