Click here to Skip to main content
15,886,592 members
Everything / Lock

Lock

lock

Great Reads

by ipavlu
The Cross-Platform Object-Oriented approach to Synchronization Primitives for .NET and .NET Core based on one shared pattern between two interfaces for General Threading and Async/Await.
by MehreenTahir
This article is a continuation of Programming Concurrency in C++ Part 1. We will discuss synchronization, future and promises along with async and with that, will sum up the introduction of concurrency in C++.
by Thomas Daniels
A tip about how to shut down, restart, log off, lock, hibernate or sleep your computer in C#.
by Liju Sankar
Find deadlocks in SQL Server using sp_who2 (an undocumented and thus unsupported stored procedure)

Latest Articles

by Uladzislau Baryshchyk
An overview of multithreading in C#
by ipavlu
The goal of the Unified Concurrency is to unify access to different synchronization primitives in object-oriented fashion with one pattern and two interfaces for general and async/await methods.
by Jason Sultana
In this post, you will see why Threadsafe is not enough
by ipavlu
The goal of the Unified Concurrency is to unify access to different synchronization primitives in object-oriented fashion with one pattern and two interfaces for general and async/await methods.

All Articles

Sort by Score

Lock 

26 May 2016 by Dave Kreskowiak
The WHERE clause in your UPDATE statement should include the status as well:UPDATE EmailMaster SET status = 'I' WHERE mailid = 12345' AND status = 'P'If the update fails, your code will know that another service has checked out the record.But, seriously, I'd have some app running that is...
24 Jul 2015 by barneyman
that's not really how SQL is designed, SQL will only lock the row/page when you start the update transaction - if you want to mark a row 'out of bounds' for editing, you'll have to implement your own lock mechanism ... perhaps a nullable datetime column on each row, which marks that row as being...
21 May 2016 by Garth J Lancaster
Quote:I'd love a way to avoid using the database as the deciding factor, but I understand if there's no other way to do it. ok .. but thats what databases are good at. You could write a similar scheme yourself - but at the end of the day, I doubt you would end up with something comparable to...
24 Mar 2019 by ipavlu
The Cross-Platform Object-Oriented approach to Synchronization Primitives for .NET and .NET Core based on one shared pattern between two interfaces for General Threading and Async/Await.
28 Feb 2024 by Richard MacCutchan
If you have no experience of creating such a program then it would probably take many months to create your own version. And since the Exelock program already offers this feature, I suggest you use that.
21 Jan 2016 by Richard Deeming
Assuming you want the return values to be 1 and 2, use the Interlocked.Increment Method[^] to increment the field, and store the result in a local variable to return at the end of the method:public class MyClass{ private int count = 0; public async Task GetCount() ...
21 May 2016 by RickZeeland
See the chapter "Working with Lock Partitioning" in this article:SQL Server Transaction Locking and Row Versioning Guide[^]Example A:BEGIN TRANSACTION -- This SELECT statement will acquire an IS lock on the table. SELECT col1 FROM TestTable WITH...
18 Sep 2016 by Maciej Los
It's almost impossible. Check previous answers to that thread: Security of software[^]
18 Sep 2016 by CPallini
In addition to Maciej solution, you could find a more realisti security model in one (or more) of these Code Project articles[^].
15 Feb 2017 by Richard MacCutchan
This is the wrong place. Try Bugs and Suggestions[^].
29 Feb 2024 by merano99
From the context, I understand that we are talking about Windows EXE programs that are to be protected with a password regardless of their location and computer. This would result in the following requirements: 1. creating password protection...
13 Nov 2012 by Shanalal Kasim
Please check below link. http://www.addictivetips.com/windows-tips/how-to-lock-and-password-protect-folder-in-vista/[^]
15 Nov 2012 by ♥…ЯҠ…♥
Alas I found the software, Folder expert password is the software i've been searching all around. But i could face some issues in that too, likeIf i unlock once by giving the password to it, it releases the folder from lock and the folder turns into normal folder.This one should...
23 Nov 2012 by srikrishnathanthri
i have tried to get “Concurrency” exception error, on sql server update using dataset (using SqlDataAdapter) and it works,but did not get any error on ms access (using OleDbDataAdapter).whether it is possible to implement optimistic lock on msAccess using dataset ?pls helpThank...
31 Jan 2013 by Simon Bridge
I have a large, enterprise scale distributed application that I am working on.I am using windows data-binding to generate data-bound forms for configuration quickly (in hours instead of weeks)The entities that I am binding to implement INotifyPropertyChanged, and the data-binding has...
15 Feb 2013 by Sergey Alexandrovich Kryukov
If some lock statement on the same object is used only in one place of the code, it is functionally equivalent to the situation when no lock is used. Isn't this obvious?Locks implement mutial exclusion mechanism which works for only for identical lock object. If two or more blocks of code...
2 Mar 2013 by afrika1
hi Guys,Am looking to develop a screen lock software1. Just something similar to a cyber cafe screen lock that locks the screen and disables ctrl alt and del, and requests a password.2. A process that runs in the background3. Would request a password everytime you logon to the...
2 Mar 2013 by Richard MacCutchan
1. What's wrong with Windows logon?2. Do you mean a service?3. See 1.4. See http://technet.microsoft.com/en-us/library/ee156540.aspx[^].
2 Mar 2013 by Ian A Davidson
It sounds as if you want to develop a Credential Provider (or, for XP or Server 2003 and earlier, a GINA dll). It would be best if you can write it so that it calls to the standard Credential Provider (or for a GINA, sits on top of the standard GINA), to avoid you having to write the...
2 Mar 2013 by Ian A Davidson
Hi afrika1,I don't think your different requirements do necessarily follow from each other.The Windows Credential Providers sit in Session 0, and gets called by the authentication sub-system. You might be able to write one to modify the look and feel of the logon screen (I'm straying into...
14 Jun 2013 by Ron Beyer
MySQL implements internal locks to guarantee consistency across applications and "sessions". A session isn't well defined in the documentation, but I would guess that a session is analogous to a connection, regardless of the username/password used. I would evaluate why you need or think you...
23 Jun 2013 by jagdish123061
Hello guys I had uploaded my asp.net website and database to server using core ftp.I had modified my database and trying to upload it to the server using core ftp but it is displaying error like 'Could not access file because it is used by another process'.because when some one opens...
17 Oct 2013 by Sergey Alexandrovich Kryukov
Oh yes, it does ensure that, but perhaps too much: it turns out to create a defect opposite to the non-serialized access: the possibility of deadlock :-).This code cannot be analyzed along, without the rest of the code, some the parts in other thread(s) awaiting on the same object and...
15 Jan 2015 by henrikxx
I'm making a program (acts as a Client) that communicates with multiple hardware devices (acts as Servers) using ethernet. If the user connects 2 hardware devices (box A and B) then I make 2 instances of these devices in software. Each of these 2 instances have each own instance of my ethernet...
1 Mar 2015 by Member 11076258
Hi, I want to create an application like lock pattern app in android. But i dont know which api or library can use for this. I'm searching this for a while but i couldn't find useful resource. Please help
1 Mar 2015 by Ravi Bhavnani
If you're looking for the Java equivalent of this C# construct:lock (sync_root) { multi_threaded_accessed_int_field++;} you can simply do this in Java:synchronized (sync_root) { multi_threaded_accessed_int_field++;}/ravi
21 Jan 2016 by Henrik R L
HiLet's say you have a function like:public class MyClass{ //Asume that this for some reason needs to be a member variable private int count=0; public async Task GetCount() { ++count; //Could be some real work to do in a...
21 Jan 2016 by Afzaal Ahmad Zeeshan
Because as per C#, it is illegal to do so. Quote[^]:An await expression cannot be used in a synchronous function, in a query expression, in the catch or finally block of an exception handling statement, in the block of a lock statement, or in an unsafe context.The thing is, if you call...
24 Mar 2016 by Simon Langdon
Can anyone provide insight into why the IE Control in our application randomly, infrequently locks up. Because we don't have access to our customer's computers, especially not in a debuggable state, this one's proving really hard to pinpoint. This is an MFC, MDI application where several...
25 Apr 2016 by Member 12485168
Hi!I'm a software developer, and i've been stuck on this problem for days, i've done so much googling but i found nothing about this....I'll try to describe this problem as easy as i can.I have 2 files, "f1" and "f2" into my directory "c:\foo\dir1\"I want to avoid any possible...
22 May 2016 by Derek Kennard
Hello Fellow Programmers, I wanted to see what the community has to say about record locking... See below: Question: What is the best way to "lock" a record so the application knows that the specific record you are editing is LOCKED and doesn't allow another user at another terminal to...
22 May 2016 by Derek Kennard
I want to thank both of you for your comments. I have reviewed them both and I have decided to go with a variation of what Garth posted. I have created an SP that uses the table name as a variable and updates a new column that indicates the record is "locked" or "unlocked"
26 May 2016 by maverick1991
I am using 3 windows services for sending bulk mail using SMTP in C#.I am selecting one row at a time using "select top 1 * from EmailMaster with (updlock) WHERE STATUS='P' ORDER BY MAILID"and then update the status to I when there is a record using Update EmailMaster set status='I'...
17 Jul 2016 by Member 12561559
Hi all,I have an app, can be resized, no code in the resize event as I am relying on dock and anchors to fill up form.Its a form, with a tabcontrol inside, and a datagrid inside each of the tabs (7 in total). If I maximise it, so its full screen, then minimize it and leave it for about 5...
15 Jul 2016 by User 11061201
That is because in such cases the Paint Events get fired numerous times and every time your Form repaints, all its children are forced to repaint too. The flickering is the result of this expensive update. What you can do is, Hide() any controls until the Form completely shows up as a whole....
17 Jul 2016 by JU571C3
try putting everything inside of a panel then the scroll will in it and to active it you just need to code in the sub were the form loads: Panel1.AutoScroll = True Panel1.VerticalScroll.Visible = False Or Panel1.HorizontalScroll.Visible = False
28 Aug 2016 by Anurita Srivastava
Consider a -slot combination lock where each slot contains a dial numbered with the ten sequential decimal integers in the inclusive range from 0 to 9. In one operation, you can choose a slot and rotate the dial by one click, either in the positive direction (to increase the displayed number by...
29 Nov 2016 by H.AL
I have created manually my logging method to log some web-methods inputs in my soap web service created on visual 2010 vb.net. As my webservice will be accessed by multiple users I have thought of lock method that locks each time the log-file. But I faced a big issue: when multiple clients...
5 Feb 2017 by Valery Possoz
Hello,In the past I did this using MakePendingFileRenameOperationsChecksum and returning a custom error code.If a file is in use and the user selects ignore, then Inno setup will set a reboot pending flag.Example script:Source: "MyProg.exe"; DestDir: "{app}";Source:...
27 Jun 2017 by PGagliardi
Hello everybody, I am struggling about how to grant the consistency of the following operation in this scenario: we are developing a reservation portal, where you can sign for courses. Every course has a number of direct reservations: when the available reservations are over, users can still...
27 Jun 2017 by PGagliardi
Ok, it seems we have found a solution:: INSERT INSERT INTO table1 (field1, field2, ..., fieldN, flag_direct_reservation) SELECT @field1, @field2, ..., @fieldN, ,CASE WHEN (SELECT COUNT(*) FROM sometable WHERE course=@course_id) > @max_part THEN 1 ELSE 0 END UPDATE (only for determining the...
25 Oct 2017 by Member 13485468
Dears, good morning. I developed a Windows Form application in Visual Studio (C#) that aims to lock the employees workstation that is logged into the machine by Windows. This application is running on the employee machine via Group Policy (GPO). Running the program locally, the code below...
25 Oct 2017 by Dave Kreskowiak
You cannot do what you're talking about because the code is running as LocalSystem, not the user. Locking the workstation is a user process. You also cannot lock the workstation for another user. You USED to be able to do this, but it hasn't worked since Win Vista or 8, I can't remember which. ...
8 Jan 2018 by Rajesh Pandya
You can dislable lock escalation. For disalbe lock escalation you can specify at the table level using ALTER TABLE tablename SET(lock_escalation = DISABLE). For more detail look at https://msdn.microsoft.com/en-us/library/ms190273.aspx If you disable it can result in higher memory consumption....
23 Oct 2019 by Richard MacCutchan
See SystemEvents Class (Microsoft.Win32) | Microsoft Docs[^].
27 Jul 2022 by Aishwarya Hegde
We have a 64 Bit .Net Application which is a Windows Form. The UI has a Live Video display which shows every Frame from a USB Camera using a delegate eventhandler. Frames are sent to this UI at 60 frames /sec. We have a need to stop the Live...
3 Mar 2019 by MehreenTahir
This article is a continuation of Programming Concurrency in C++ Part 1. We will discuss synchronization, future and promises along with async and with that, will sum up the introduction of concurrency in C++.
1 Dec 2014 by Thomas Daniels
A tip about how to shut down, restart, log off, lock, hibernate or sleep your computer in C#.
8 Jan 2015 by Liju Sankar
Find deadlocks in SQL Server using sp_who2 (an undocumented and thus unsupported stored procedure)
6 May 2021 by ipavlu
The goal of the Unified Concurrency is to unify access to different synchronization primitives in object-oriented fashion with one pattern and two interfaces for general and async/await methods.
29 Feb 2024 by Maxim Kartavenkov
To implement that you need to have the base program which performs an encryption your exe with the given password and create primary executable - let's call this application "Creator". In this application you specify the password and select an...
21 Jan 2021 by ipavlu
The goal of the Unified Concurrency is to unify access to different synchronization primitives in object-oriented fashion with one pattern and two interfaces for general and async/await methods.
1 Mar 2022 by Uladzislau Baryshchyk
An overview of multithreading in C#
24 Aug 2016 by Roman Ivantsov
The article provides a comparative analysis and gives patterns of using explicit locks to manage concurrent access to database documents (data split over multiple tables) in MS SQL Server, MySql, PostgreSql and Oracle. As it turned out, the solution is not always obvious or simple.
6 Apr 2021 by Jason Sultana
In this post, you will see why Threadsafe is not enough
22 May 2016 by Pavel Durov
Calling async function inside lock block
25 Jun 2013 by Kaushik S Murthy
This application allows you to know the status of caps lock whenever the caps status is toggled
15 Feb 2013 by nidhin1984
I have two method “ExecuteNoQuery” (performs dbCommand.ExecuteNonQuery()) and “Query” performs (dbCommand.ExecuteReader()). Both the methods are using same connection object. In ExecuteNoQuery method a lock is implemented(using connection object) and Query method implemented with out lock. In...
6 Feb 2017 by Member 12983131
When files are locked during the silent Inno Setup(actually the update), user gets MsgBox allowing him to ignore file replacement. After setup is finished, the process exists with ExitCode=0 meaning setup is completed. Since not all files are replaced, you can not be 100% sure that setup is...
17 Oct 2013 by Member 10338805
lock.lock(); //lockif(nReaders > 0){readers.await(); }//awaitnReaders++;...nReaders--;readers.signal(); //signallock.unlock(); //lockI tried using it so that my global variable stays consistent throughout the execution of my program, but it doesn't work...
14 Jun 2013 by Member 9856173
Hello,MySQL documentation says that LOCK command locks tables for a "session". I am confused that what is session??? does it mean user???I am making a software that uses MySQL for database. I have hard coded the user name and password for MySQL connection in the software i.e. all the...
24 Jul 2015 by Member 11495494
hii have searched alooooot for last 4 days..i have read allll the questions and articles and evry thing .. but i cant figure it outmy question is :i have an mfc application connected to a sql server database via odbci want to lock a row when im editing itits easy in many ereas .. even...
28 Feb 2024 by Uzbek Tv yangiliklari
I have no any idea on creating a gui program that locks an exe file with given password by user, and when user tries to open that exe app, a form should appear and ask for the password to open that exe app for user, no matter the exe file's name...
13 Nov 2012 by ♥…ЯҠ…♥
Hi friends, I try to explain clearly the requirements, I want third party application to lock the folder in my windows 7. Simple is'nt?So my requirement is, the Folder I intend to lock should be visible to me,When I double click(or open) the locked folder, it should ask for...
2 Mar 2013 by afrika1
thanks for your reply, Answers to Richard MacCutchan1. There is nothing wrong with the windows logon. We just would prefer to do something inhouse as well to monitor and restrict users ( In our own way ) ... HENCE REASON AM ASKING.2. I dont know if its a service, as i said i...
5 Mar 2013 by afrika1
thanks again Ian,but am not looking to customise the windows logon.I do appreciate your replies and advise, but as I asked very simply.We are looking to develop a software that would run AFTER ( I REPEAT ) After the user logs in, even the administrator to control the screen. We...
18 Sep 2016 by Member 11003365
I am developing a windows from application in c# and I want to Lock my software no to be usable by another pepole . so please help me to do thisWhat I have tried:I have done no thing because I didnot know what to do
8 Jan 2018 by Tamanna Sharma
Hi, My question is regarding concurrency and locking mechanism. In my project, Informatica and SQL procedures have to process on a single SQL table. Process 1: Informatica dumps a set of records into SQL table X. Then SQL procedure need to take that set from X to process and then dump the...
23 Oct 2019 by Member 11426986
I need to identify when the user locks up their Windows Operating System user, or the user goes into hibernation, or sleep, and takes action. What I have tried: SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(OnPowerModeChanged); private static void...
13 May 2022 by Hibat Ullah
button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundImage(); } }); } private void setBackgroundImage() { Bitmap...