Click here to Skip to main content
15,916,702 members
Home / Discussions / C#
   

C#

 
GeneralRe: Subjective question: which one of these Lazy Init is best Pin
Super Lloyd20-Oct-17 23:01
Super Lloyd20-Oct-17 23:01 
GeneralRe: Subjective question: which one of these Lazy Init is best Pin
BillWoodruff21-Oct-17 0:44
professionalBillWoodruff21-Oct-17 0:44 
GeneralRe: Subjective question: which one of these Lazy Init is best Pin
Super Lloyd21-Oct-17 1:21
Super Lloyd21-Oct-17 1:21 
QuestionRe: Subjective question: which one of these Lazy Init is best Pin
Super Lloyd20-Oct-17 21:10
Super Lloyd20-Oct-17 21:10 
AnswerRe: Subjective question: which one of these Lazy Init is best Pin
Sascha Lefèvre21-Oct-17 2:54
professionalSascha Lefèvre21-Oct-17 2:54 
GeneralRe: Subjective question: which one of these Lazy Init is best Pin
BillWoodruff22-Oct-17 6:08
professionalBillWoodruff22-Oct-17 6:08 
QuestionAttributes on fields in a DataTable/DataRow Pin
hpjchobbes18-Oct-17 10:27
hpjchobbes18-Oct-17 10:27 
AnswerRe: Attributes on fields in a DataTable/DataRow Pin
Gerry Schmitz18-Oct-17 18:08
mveGerry Schmitz18-Oct-17 18:08 
QuestionHow to reverse an array without using Array.Reverse()? Pin
Mubi Ace17-Oct-17 4:58
Mubi Ace17-Oct-17 4:58 
AnswerRe: How to reverse an array without using Array.Reverse()? Pin
Eddy Vluggen17-Oct-17 5:22
professionalEddy Vluggen17-Oct-17 5:22 
GeneralRe: How to reverse an array without using Array.Reverse()? Pin
Richard Deeming17-Oct-17 9:08
mveRichard Deeming17-Oct-17 9:08 
QuestionHow can I change an icon in the Windows taskbar at run time? Pin
Member 1063109916-Oct-17 11:30
Member 1063109916-Oct-17 11:30 
QuestionHow to prevent stopping application Pin
Mou_kol16-Oct-17 4:12
Mou_kol16-Oct-17 4:12 
AnswerRe: How to prevent stopping application Pin
OriginalGriff16-Oct-17 4:31
mveOriginalGriff16-Oct-17 4:31 
SuggestionRe: How to prevent stopping application PinPopular
Richard Deeming16-Oct-17 7:56
mveRichard Deeming16-Oct-17 7:56 
AnswerRe: How to prevent stopping application Pin
jschell17-Oct-17 7:24
jschell17-Oct-17 7:24 
SuggestionFYI: FileOptions.WriteThrough / FileStream.Flush(true) / FlushFileBuffers Pin
Sascha Lefèvre15-Oct-17 0:28
professionalSascha Lefèvre15-Oct-17 0:28 
(Not a question, not a Tip/Trick in my eyes. Wanted to share and didn't see a better place for it.)

I'm implementing a write-ahead log (WAL) for an application and was searching for an answer on how to make sure a file actually gets written to disk when I close the FileStream and doesn't linger in one of the intermediary I/O caches, being vulnerable to system power loss.

There's a lot of confusion "in the webs" about which way is actually working:
- FileOptions.WriteThrough / FILE_FLAG_WRITE_THROUGH
- FileStream.Flush(flushToDisk: true)
- Win32.FlushFileBuffers

I was about to ask here when I finally found this:
Revised notes on the reliability of FlushFileBuffers – The Old New Thing[^]

tl;dr: FlushFileBuffers is the way to go on Windows 8 and newer (also best bet on Win7), FileOptions.WriteThrough might work as well but probably not, blame the storage device manufacturers.

Looking into the source of FileStream (.NET 4.7) I saw that all FileStream.Flush(flushToDisk: true) actually does is to call Win32.FlushFileBuffers. On my Google journey I found "hints" that this might not always have been the case, so if you need it, you should look into the source of the .NET version you're using.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

Questionvoipsdk.dll..... basic ivr c# Pin
karimkarimkarim13-Oct-17 14:50
karimkarimkarim13-Oct-17 14:50 
AnswerRe: voipsdk.dll..... basic ivr c# Pin
Richard Andrew x6413-Oct-17 16:38
professionalRichard Andrew x6413-Oct-17 16:38 
QuestionC# multitasking Pin
Member 1346321013-Oct-17 0:51
Member 1346321013-Oct-17 0:51 
AnswerRe: C# multitasking Pin
OriginalGriff13-Oct-17 1:59
mveOriginalGriff13-Oct-17 1:59 
QuestionThread WaitReason.UserRequest Pin
Bernhard Hiller12-Oct-17 21:44
Bernhard Hiller12-Oct-17 21:44 
QuestionC# - run exe from within a form, and keep the exe's borders within the actual boundary of the form... Pin
Member 1184284812-Oct-17 13:38
Member 1184284812-Oct-17 13:38 
AnswerRe: C# - run exe from within a form, and keep the exe's borders within the actual boundary of the form... Pin
Afzaal Ahmad Zeeshan12-Oct-17 16:24
professionalAfzaal Ahmad Zeeshan12-Oct-17 16:24 
GeneralRe: C# - run exe from within a form, and keep the exe's borders within the actual boundary of the form... Pin
BillWoodruff20-Oct-17 16:47
professionalBillWoodruff20-Oct-17 16:47 

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.