Re: locking objects

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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


.



Relevant Pages

  • Re: NadaNet for the //c - just an idea
    ... chip/etc before/after each packet to be sent/received? ... control over write protect with the drive still running, ... properly *throughout* a whole request. ... able to write to the net to assert its lock). ...
    (comp.sys.apple2)
  • Re: set combobox properties for subform on another tab
    ... with a tab control. ... Tab1 is a subform with a checkbox. ... subform to "Mandated" and lock it. ... After you get the proper value assigned to the combo box, ...
    (microsoft.public.access.formscoding)
  • Re: Prevent edits - unexpected effects
    ... No editing has begun at this stage, so there is no danger, (unless you are also assigning a value to a bound control in Form_Current.) ... When you click the button to lock the form, it attempts to save the record before doing anything else. ... Or did you misunderstand and use the AfterUpdate of the control instead of the form? ... were to click the 'Complete' checkbox on a new record w/o first having ...
    (microsoft.public.access.forms)
  • Re: Form when populate execute code
    ... it's just an example) when it's finish we change the ticket status from ... the code, i even check if it lock the form and it's not, if i do it on ... Dim c2 As Control ... Using Windows XP pro latest patch ...
    (microsoft.public.access.formscoding)
  • Form when populate execute code
    ... the code, i even check if it lock the form and it's not, if i do it on ... Dim c2 As Control ... Using Windows XP pro latest patch ...
    (microsoft.public.access.formscoding)