in Education by
Basically I want to achieve using a lock to a property that has no private variable, the goal is to have thread safe Properties instead of doing it manually each time. But not sure how to write that, so the lines aren't red! :) public class TestingLOL { public int Id { get; set; } // Working non private property but is not thread safe. public int IdWithLock { get => lock (this); set; } // this is what im trying to achieve without a private property. private int shitMethod; public int ShitMethod // **** this way { get { ; lock (this) return shitMethod; } set { ; lock (this) shitMethod = value; } } } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
For this to work you have to use the name of that backing field public int IdWithLock { get => { lock (this){return XXXX;}}; set; } but that name is not available to you (see nice long discussion here Is it possible to access backing fields behind auto-implemented properties?) You just gonna have to do it the shty way

Related questions

0 votes
    I'm having some trouble recently. On a WebForm I declare a static object, like this : public static ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I'm having some trouble recently. On a WebForm I declare a static object, like this : public static ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I'm having some trouble recently. On a WebForm I declare a static object, like this : public static ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    The database system must take special actions to ensure that transactions operate properly without interference ... Concept topic in chapter Transactions of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    Is it possible to specify the jvm that the eclipse installer will use? I'm getting the error "Version ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Let's say I have the following simple table variable: declare @databases table ( DatabaseID int, Name ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    How can I determine the space used by a table variable without using DATALENGTH on all columns? eg: DECLARE ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    AAE's "PDF Integration" command allows you to split a .pdf into a separate single file for a selected number ... by the hyphen. Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    write algorithm and flowchart the inputs two numbers swaps these values without using third variable Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    write a program in c++ to interchange 2 values without the 3rd variable. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    I have a web page that accepts an excel file, reads data from it and stores it in a buffer table ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    How do I parse a string eg. "01/21 - 02/20" which is represented as month/day to month/day. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    I want put perfect percentage on each chart column as shown in fig in C# Windows Forms. How would ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    I want to put a value from database because my dropdown already have a value the same as the text ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    I want to convert an int to a byte[2] array using BCD. The int in question will come from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
...