Click here to Skip to main content
15,884,237 members
Home / Discussions / C#
   

C#

 
QuestionHow can i write application in Doc/view architecture in C# ? Pin
Yanshof14-Jan-08 19:14
Yanshof14-Jan-08 19:14 
AnswerRe: How can i write application in Doc/view architecture in C# ? Pin
Pete O'Hanlon15-Jan-08 3:16
mvePete O'Hanlon15-Jan-08 3:16 
QuestionNative XP/Vista Menu Pin
KienNT7814-Jan-08 17:53
KienNT7814-Jan-08 17:53 
GeneralRe: Native XP/Vista Menu Pin
Paul Conrad17-Jan-08 13:31
professionalPaul Conrad17-Jan-08 13:31 
GeneralRe: Native XP/Vista Menu Pin
Laserson24-Aug-09 19:38
Laserson24-Aug-09 19:38 
Generaldebugging Pin
justintimberlake14-Jan-08 17:22
justintimberlake14-Jan-08 17:22 
GeneralRe: debugging Pin
Skippums14-Jan-08 17:32
Skippums14-Jan-08 17:32 
QuestionDoes a race condition exist in the following code? Pin
Skippums14-Jan-08 14:57
Skippums14-Jan-08 14:57 
I have a WS that has a number of methods, and two in particular must share a file. My question is, will the finally block in the following code run while the lock is acquired, or will it release the lock, then run the finally block?
public byte[] GetFile(string fileName) {
    FileStream fs = null;
    try {
        // Do some stuff that CANNOT be done after acquiring the lock
        lock (s_Lock) {
            fs = new FileStream(..., FileShare.None, ...);
            byte[] result = new byte[fs.Length];
            fs.Read(result, 0, fs.Length);
            return result;
        }
    } finally {
        if (fs != null)
            fs.Close();
    }
}
public bool DeleteFile(string fileName) {
    lock (s_Lock) {
        File.Delete(fileName);
    }
}
The thing I am worried about is that I am opening the file with no sharing allowed, so I want other calls for the same file to wait for the file to become accessible. So if GetFile is currently being run (has the lock) and DeleteFile is waiting for the lock (both with the same file name argument), then is it possible that prior to the call to fs.Close() that the DeleteFile method attempts to remove the file (which would result in an exception since the file is already open)? Thanks,

Sounds like somebody's got a case of the Mondays

-Jeff

GeneralRe: Does a race condition exist in the following code? Pin
S. Senthil Kumar14-Jan-08 18:03
S. Senthil Kumar14-Jan-08 18:03 
GeneralRe: Does a race condition exist in the following code? Pin
Skippums15-Jan-08 4:48
Skippums15-Jan-08 4:48 
GeneralRe: Does a race condition exist in the following code? Pin
PIEBALDconsult15-Jan-08 15:45
mvePIEBALDconsult15-Jan-08 15:45 
GeneralRe: Does a race condition exist in the following code? Pin
Pete O'Hanlon16-Jan-08 1:20
mvePete O'Hanlon16-Jan-08 1:20 
QuestionDynamic Method Delegate [modified] Pin
Gywox14-Jan-08 14:25
Gywox14-Jan-08 14:25 
GeneralRe: Dynamic Method Delegate Pin
Mark Churchill14-Jan-08 21:49
Mark Churchill14-Jan-08 21:49 
GeneralRe: Dynamic Method Delegate Pin
Gywox14-Jan-08 23:26
Gywox14-Jan-08 23:26 
GeneralRe: Dynamic Method Delegate Pin
Mark Churchill15-Jan-08 2:00
Mark Churchill15-Jan-08 2:00 
GeneralComponent1 vs Infragistics vs Syncfusion Pin
kozu14-Jan-08 13:03
kozu14-Jan-08 13:03 
GeneralRe: Component1 vs Infragistics vs Syncfusion Pin
Not Active14-Jan-08 14:31
mentorNot Active14-Jan-08 14:31 
GeneralRe: Component1 vs Infragistics vs Syncfusion Pin
J$14-Jan-08 14:44
J$14-Jan-08 14:44 
GeneralRe: Component1 vs Infragistics vs Syncfusion Pin
kozu14-Jan-08 18:15
kozu14-Jan-08 18:15 
GeneralRe: Component1 vs Infragistics vs Syncfusion Pin
Nouman Bhatti14-Jan-08 22:32
Nouman Bhatti14-Jan-08 22:32 
GeneralRe: Component1 vs Infragistics vs Syncfusion Pin
IAM...13-Mar-10 14:01
IAM...13-Mar-10 14:01 
Questionprogramming into smart card Pin
roonierobster14-Jan-08 12:04
roonierobster14-Jan-08 12:04 
QuestionC# .NET and a networked PC with MySQL running Pin
CoolBytes14-Jan-08 11:48
CoolBytes14-Jan-08 11:48 
GeneralRe: C# .NET and a networked PC with MySQL running Pin
DaveyM6914-Jan-08 12:10
professionalDaveyM6914-Jan-08 12:10 

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.