Re: locking objects
- From: "Pohihihi" <noemail@xxxxxxxxxxx>
- Date: Wed, 28 Dec 2005 11:22:55 -1000
"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1e1c97c8ba1874db98cbfa@xxxxxxxxxxxxxxxxxxxxxxx
> Pohihihi <noemail@xxxxxxxxxxx> wrote:
>> Basically I am creating thread to access db and load a dataset but the
>> part
>> when dataset is filled i am putting a lock (in case a next request).
>
> Note that if this is within a Windows Forms app and the dataset is
> bound to a control, you should only do the filling within the UI
> thread.
Yes it is connected with 3rd party control.
........>> and fill the dataset with information for visible month.
> So are you creating the new thread within the change event?
DAL has method that I call to fill ds in UI thread but via creating a thread
to access db which in turn returns and fills a ds and prompts a event to
fill final ds. Little extra work but this is were I have lock to fill final
ds.
..........
>> threads are holding in memory. bottom line is what could be a better
>> option.
> Well, if you're using a SqlCommand, you could cancel the current
> command if one is executing when the user clicks. That's the most
> efficient way of doing things without waiting to see if there are more
> clicks coming.
I don't have control over sqlcommand statement. It is a method to access db
in DAL and I pass params. Non of the method supports cancellation. It will
be a good way but is there a way all together to avoid network traffic by
sending only that request which will be consumed on return. I am kind of
thinking that I am stuck with the option of waiting for say 3 second before
sending the request but I also understand that this is a limited solution
for my problem. I guess my thought process is kind of stuck with this and
limiting me to think more.
> As Truong said, the lock statement itself doesn't have a timeout.
> However, if you want locking with timeouts, it's quite possible to do
> it - see http://www.pobox.com/~skeet/csharp/threads/alternative.shtml
> I'm hoping to upload a new version of MiscUtil with deadlock detection
> in the next day or two - the code is written, it just needs potentially
> renaming and documenting :)
I will surely use it. Are you going to open the code as well?
>
> --
> Jon Skeet - <skeet@xxxxxxxxx>
> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
> If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: locking objects
- From: Jon Skeet [C# MVP]
- Re: locking objects
- References:
- locking objects
- From: Pohihihi
- Re: locking objects
- From: Jon Skeet [C# MVP]
- Re: locking objects
- From: Pohihihi
- Re: locking objects
- From: Jon Skeet [C# MVP]
- locking objects
- Prev by Date: Re: locking objects
- Next by Date: Re: Can you write code directly in CIL ???
- Previous by thread: Re: locking objects
- Next by thread: Re: locking objects
- Index(es):
Relevant Pages
|