Click here to Skip to main content
15,891,657 members
Home / Discussions / C#
   

C#

 
QuestionDataBound DataGridView Relational DB Problem Pin
shirazamod19-Nov-07 5:03
shirazamod19-Nov-07 5:03 
AnswerRe: DataBound DataGridView Relational DB Problem Pin
pmarfleet19-Nov-07 9:04
pmarfleet19-Nov-07 9:04 
GeneralRe: DataBound DataGridView Relational DB Problem Pin
shirazamod19-Nov-07 9:45
shirazamod19-Nov-07 9:45 
GeneralRe: DataBound DataGridView Relational DB Problem Pin
pmarfleet19-Nov-07 9:50
pmarfleet19-Nov-07 9:50 
QuestionEnumerators and locks. Pin
jmhamm19-Nov-07 4:40
jmhamm19-Nov-07 4:40 
AnswerRe: Enumerators and locks. Pin
Bekjong19-Nov-07 5:00
Bekjong19-Nov-07 5:00 
GeneralRe: Enumerators and locks. Pin
jmhamm19-Nov-07 5:08
jmhamm19-Nov-07 5:08 
AnswerRe: Enumerators and locks. Pin
Daniel Grunwald19-Nov-07 11:42
Daniel Grunwald19-Nov-07 11:42 
When you compile this code:
IEnumerable<string> Test() {
  lock (someObj) {
    yield return "a";
    yield return "b";
  }
}


Then the C# compiler creates an enumerator class that calls Monitor.Enter on the first MoveNext call; and calls Monitor.Exit in the third MoveNext call, or in the Dispose method if Dispose is called between after the first MoveNext call and before the third.
foreach will automatically dispose the enumerator, but I've seen people write code like
IEnumerable<MyType> myCollection = ...;
if (e.GetEnumerator.MoveNext()) { // if the collection is not empty


So yes, using Monitor.Exit in the Dispose function is the way locking is meant to happen in enumerators, but make sure that your team is aware of the fact that enumerators must be disposed!



QuestionFindControl on Fields on an aspx screen. Pin
imnotso#19-Nov-07 4:33
imnotso#19-Nov-07 4:33 
AnswerRe: FindControl on Fields on an aspx screen. Pin
Anthony Mushrow19-Nov-07 4:42
professionalAnthony Mushrow19-Nov-07 4:42 
GeneralRe: FindControl on Fields on an aspx screen. Pin
imnotso#19-Nov-07 4:58
imnotso#19-Nov-07 4:58 
AnswerRe: FindControl on Fields on an aspx screen. Pin
martin_hughes19-Nov-07 5:27
martin_hughes19-Nov-07 5:27 
GeneralRe: FindControl on Fields on an aspx screen. Pin
imnotso#19-Nov-07 5:36
imnotso#19-Nov-07 5:36 
GeneralRe: FindControl on Fields on an aspx screen. Pin
Anthony Mushrow19-Nov-07 5:42
professionalAnthony Mushrow19-Nov-07 5:42 
GeneralRe: FindControl on Fields on an aspx screen. Pin
imnotso#19-Nov-07 5:55
imnotso#19-Nov-07 5:55 
GeneralRe: FindControl on Fields on an aspx screen. Pin
Anthony Mushrow19-Nov-07 6:08
professionalAnthony Mushrow19-Nov-07 6:08 
GeneralRe: FindControl on Fields on an aspx screen. Pin
imnotso#19-Nov-07 6:13
imnotso#19-Nov-07 6:13 
QuestionBreak out of a loop Pin
Programm3r19-Nov-07 4:16
Programm3r19-Nov-07 4:16 
AnswerRe: Break out of a loop Pin
led mike19-Nov-07 4:34
led mike19-Nov-07 4:34 
GeneralRe: Break out of a loop Pin
Programm3r19-Nov-07 4:36
Programm3r19-Nov-07 4:36 
GeneralRe: Break out of a loop Pin
led mike19-Nov-07 4:55
led mike19-Nov-07 4:55 
AnswerRe: Break out of a loop Pin
J4amieC19-Nov-07 4:34
J4amieC19-Nov-07 4:34 
AnswerRe: Break out of a loop Pin
Shpendh19-Nov-07 5:31
Shpendh19-Nov-07 5:31 
GeneralRe: Break out of a loop Pin
Colin Angus Mackay19-Nov-07 6:04
Colin Angus Mackay19-Nov-07 6:04 
GeneralRe: Break out of a loop Pin
J4amieC19-Nov-07 6:20
J4amieC19-Nov-07 6:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.