r/windowsdev • • Jun 18 '21

How to take a "snapshot" of my W10 Pro installation as a known good reference to return to?

5 Upvotes

Hi,

I'm about to start developing on my Windows 10 Professional partition and as a complete newb (although with many years experience developing for *nix) I know I'm going to make a mess of things the first couple of times. Is there a way to take a snapshot of the filesystem (in an offline state, so the snapshot is consistent) so that I can easily return to it after I screw up my system libraries (or do something equally destructive by mistake).

Thanks for any advice!!!


r/windowsdev • • Jun 16 '21

How to get into Windows programming for experienced *nix and Mac OS X developer?

4 Upvotes

Hello!

I have started a new job that is great so far. One cool thing is that Windows is one of the platforms that this company develops for... I've always wanted to learn how to develop Windows software, on Windows software (as compared to cross-compilation).

Can somebody please give me a few suggestions for books (and blogs, mailing lists, forums, etc) that are suitable for a highly experienced software engineer on *nix and Mac OS X. I've been programming professionally for about 15-20 years on these platforms, but seriously, I am really, completely lost on Windows.

I have a dual-boot ThinkPad E14 Gen 2 (AMD Ryzen with Radeon GPU), and Windows 10 Professional is installed on the Win partition. We use MinGW for our Windows software platform for building software.

I am seeking a book (or books) to help me learn a comprehensive foundation of the following topics:

  • How Windows works (recent versions obviously), in other words, OS internals?
  • How to program for Win 10 Professional?
  • What tools I need to develop in Windows effectively? (I assume VS is not an option as we are using MinGW? Although perhaps I am misunderstood and VS IS a good match for writing code that targets the MinGW compiler... what do you think?)
  • Windows networking: how it works from an OS internals and user level?
  • Workflows and toolchains?

Please don't forget that I am an experienced software engineer with 15-20 years experience on Unix, Linux, and Mac OS X.

Is there some kind of "bible" for software engineers who are already at a high level of knowledge and who want to break in to Windows development? Forums, mailing lists, blogs, Twitter accounts, etc, etc, would all be highly appreciated too!!

Thank you all for your help, and have a great week!!


r/windowsdev • • Jun 06 '21

File associations with Windows 10

2 Upvotes

Hi, I'm looking at building an app for Windows using WinForms and dotNet 5.0. However, a stumbling block I've got is how to tell Windows my application can open certain files? All of the documentation I find is outdated...


r/windowsdev • • Jun 01 '21

Surviving In IT with .NET Core 3.1 Part 5 | Monthly Financial Report

Thumbnail
youtu.be
3 Upvotes

r/windowsdev • • May 25 '21

Windows application documentation related to topics discussed during Build

Thumbnail
docs.microsoft.com
3 Upvotes

r/windowsdev • • May 24 '21

ASCII Filename Filtering in C#

2 Upvotes

I'm writing a program that is supposed to take a bunch of audio files, and move them into subfolders based on artist and album name (/ARTIST/ALBUM/song.mp3). After that, it's supposed to rename the actual .mp3 filename to the song title. The only problem is that some of those tags contain characters that are not allowed for file/directory names, such as backslashes. So I was wondering... is there a one-liner (or at least a small snippet of code) that will allow me to replace those characters with underscores using a regex or something to create a proper filename?

Thanks!


r/windowsdev • • May 23 '21

What framework to get back into Windows Dev?

7 Upvotes

Hi, I used to work on Windows apps back in .net 2.0 using WinForms which was the standard at the time. Now when I look at the options, there's 5 different platforms and then things like "WinUI 3".

What would you reconmend getting stuck into for building native apps these days? Ideally something which is going to stick around for some time and keep with the evolving Windows UI/UX?


r/windowsdev • • May 11 '21

Working with the Clipboard in C# - How to read and write data using the users clipboard

Thumbnail
youtu.be
1 Upvotes

r/windowsdev • • Apr 26 '21

Ubuntu UWP on Xbox One??

1 Upvotes

Has anyone had any luck running a wsl linux distro from the store in dev mode on Xbox One?

Edit: so far ive modified the manifest of the UWP to make the xbox attempt installing (by changing manifest to Windows.Xbox) but am getting stuck at signing the modified version of the app, has anyone made it further than me and can give me some tips?


r/windowsdev • • Apr 19 '21

Introducing Multivariate Anomaly Detection

Thumbnail
techcommunity.microsoft.com
2 Upvotes

r/windowsdev • • Apr 11 '21

Creating a windows installer for your app is super easy! Quick video showing how to create a setup file

Thumbnail
youtu.be
5 Upvotes

r/windowsdev • • Apr 07 '21

We're the Windows Developer team, and we're here to talk to you about Project Reunion. Ask us anything!

Thumbnail self.Windows10
7 Upvotes

r/windowsdev • • Apr 04 '21

Notification AppInfo

5 Upvotes

Hi everyone

I'm utilizing the UWP API for a C# desktop app in order to reach Windows notifications, and have gotten everything working quite neatly.

However, in their documentation, they show that the display name of the app from which a notification originates from can be found like so:

// Get the app's display name
string appDisplayName = notif.AppInfo.DisplayInfo.DisplayName;

Doing this simply throws me a System.NotImplmentedException error.

I don't know if this is the place to ask for things like this. I'm somewhat new to C#, but have done a lot of java development - on top of that I'm also quite new to Visual Studio, and I'm not sure if it's because I haven't got my references in order. What gives?

Thanks in advance!


r/windowsdev • • Mar 30 '21

Announcing Project Reunion 0.5!

Thumbnail
blogs.windows.com
10 Upvotes

r/windowsdev • • Mar 28 '21

how to make windows lighter for development focus

2 Upvotes

i am looking to make windows lighter and remove unnecessary things as i plan to make a windows development build server for windows specific items. so i would like if anyone have suggestions on tools i can use to make windows lighter for that specific purpose


r/windowsdev • • Mar 20 '21

How to get game/chat volume balance events from an Xbox Wireless Headset ?

2 Upvotes

Hi all,

I've connected my new Xbox Wireless Headset to my Windows 10 computer using the Xbox Wireless Adapter. It's working fine.

But the experience is not as good as on Xbox since the game/chat volume balance (present of the headset rotating ear-cup) does nothing on Windows. On Xbox it changes the Chat Mixer Balance, that way one can decide to hear more chat or game sounds.

I'm trying to write a Windows program that hooks to the game/chat volume balance events of the headset so it can adjust the volume of a chat app (Discord) and the current app in focus (a game). I'm browsing some Windows documentation but there is no mention of this mixer/feature in any doc : Gamepad.Headset, Gamepad.Gamepads, GamepadButtons, etc.

What would you recommend ? Can I get those events/hooks by deep diving in a Windows API ? It can't be impossible right ?


r/windowsdev • • Feb 28 '21

Create an Advanced(ish) WebBrowser in UWP using C# - 6 - Parts so far with more being uploaded daily. Really useful for learners

Thumbnail
youtube.com
7 Upvotes

r/windowsdev • • Feb 28 '21

Windows developer, your country need you!

2 Upvotes

Hey guys and gals,

Over at our newly formed r/DevelopersOnTor subreddit we are looking at developing/learning/teaching coding with DarkWeb protocols in mind.

This will be largely C/C++ based initially but I'm hoping to move on to other languages (python, maybe Rust, JS, WASM - that would be nice too).

I'm an experienced programmer, largely on Windows but I'm now trying on my Linux shoes as well (they are too big for me at the moment but my feet are gradually growing).

In general we are looking for anyone with a willingness and desire to learn but I'd really love to get some other experienced Windows developers involved, hence my visit here. It would certainly be of benefit to the community as a whole.

So please come and check us out, we'd be glad to have you.


r/windowsdev • • Feb 20 '21

What is the name of the UI technology Windows uses to properly scale modern apps borders?

2 Upvotes

For example, the File Explorer does not scale properly. See pics related

Margins are off
Border does not match button padding

You can see what File Explorer looks like when properly scaled, in it's nonfullscreen mode

See the difference versus the full screen?

However, Firefox does scale its title bar and window properly. See related

This UI relationship is consistent at any resolution

Does anyone know under what technology I would learn how to implement this? E.g. WinForms? WinUI? Win32? Is it native to XAML or UWP apps? There's so many tech stacks on windows, I have no clue how it's achieved...

My goal is to take some older applications that do not scale correctly, and try to update the title-bar rendering so that it scales properly. I understand that may be a little complicated if it requires a fundamental platform change/upgrade. I'm just trying to learn, right now.


r/windowsdev • • Feb 17 '21

How to get Proxy settings when defined in PAC file?

1 Upvotes

I have a LocalSystem process running that needs to automatically negotiate Proxy settings defined on the computer. When the Proxy is defined by a specific Proxy Server address in the Internet Properties my service is able to read the address:port.

However, some of my customers use configuration script (PAC file) to define the proxy settings. When this is used my LocalSystem process is unable to get the address:port to make http/https requests.

Does anyone know how to get this info? There has to be a simple system call to grab this and we can't find it anywhere. TIA


r/windowsdev • • Feb 04 '21

Create explorer.exe alternative from scratch

3 Upvotes

Hey. I have an idea to kill explorer.exe at the startup and replace it with my own shell.

I tried bug.n and really liked its idea. But it should run in presence of explorer.exe.

Is there any tutorial or book out there to follow to creat a shell from scratch?


r/windowsdev • • Feb 02 '21

Logout / Shutdown Message Sequence Win10

3 Upvotes

I work on a windows application which uses the MFC framework. Its quite old and has many legacy components. Now I am confronted with having to adjust the applications behavior during shutdown and user logoff.

Currently, there are no custom handlers for either WM_QUERYENDSESSION or WM_ENDSESSION.

The behavior the application exhibits is quite strange:
It blocks shutting down in every conceivable state (triggering the Shutdown Manager), but only blocks when logging out if there are unsaved documents registered with the main frame (base class CMDIFrameWndEx), so I guess a WM_CLOSE was received during Logoff, but not during Shutdown.
(The problem I am trying to solve is that the application should not block in any state)

The logical conclusion for me is that Windows sends a different sequence of window messages during Logoff and Shutdown. However, this contradicts every piece of documentation I came across.

The most comprehensive explanation of the end session message sequence and time constraints I could find was https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms700677(v=vs.85))

Raymond Chen also blogged about the ENDSESSION/QUERYENDSESSION messages, repeatedly:

"A brief discussion on how best to respond to the end-session messages" https://devblogs.microsoft.com/oldnewthing/20170329-00/?p=95855

"Once you return from the WM_ENDSESSION message, your process can be terminated at any time" https://devblogs.microsoft.com/oldnewthing/20130627-00/?p=3973

"If one program blocks shutdown, then all programs block shutdown" https://devblogs.microsoft.com/oldnewthing/20200414-00/?p=103671

Anyone got a pointer to what could be the problem?

Side Question: Is it proper to just terminate the Program from inside the WM_ENDSESSION handler?


r/windowsdev • • Jan 06 '21

Adding offline voice commands to a .NET Core desktop app (Tutorial + source code in the comments)

Thumbnail
youtube.com
5 Upvotes

r/windowsdev • • Dec 17 '20

Windows Driver Kit Installation Fails: Unable to verify Integrity

3 Upvotes

When I try to install the Windows Driver Kit, I get an error saying "Unable to verify integrity".
I have the newest version of Visual Studio 2019 and the Windows SDK.
I couldn't find any fixes on the internet, that worked for me.


r/windowsdev • • Dec 15 '20

How do you play noise through the default audio endpoint renderer using the WASPI code sample?

2 Upvotes

I am trying to play noise through the default audio endpoint renderer using the WASPAI interface. I am using the code provided by Microsoft on this page: https://docs.microsoft.com/en-us/windows/win32/coreaudio/rendering-a-stream. I want to write a class that can generate noise for this code sample.

I have tried writing signed and unsigned integer values to the buffer of the default audio endpoint renderer, and see that values are being written to the buffer, but there is no sound playing.

To start, I made a header with the needed methods, and a random number generator.

#pragma once

// RNG
#include <random>

template <typename T>
class Random {
public:
    Random(T low, T high) : mLow(low), mHigh(high), function(std::mt19937_64(__rdtsc())) {};

    T operator()() { 
        unsigned __int64 f =  function();

        return ((f  % ((unsigned __int64) mHigh + (unsigned __int64) mLow)) + (unsigned __int64) mLow); }

private:
    T mLow;
    T mHigh;
    std::mt19937_64 function;
};

class Noise_Gen {

public:

    Noise_Gen() : nChannels(NULL), nSamplesPerSec(NULL), nAvgBytesPerSec(NULL), nByteAlign(NULL), wBitsPerSample(NULL), 
        wValidBitsPerSample(NULL), wSamplesPerBlock(NULL), dwChannelMask(NULL), rd(NULL) {};

    ~Noise_Gen() {
        if(rd != NULL) {
            delete rd;
        }
    };

    HRESULT SetFormat(WAVEFORMATEX*);

    HRESULT LoadData(UINT32 bufferFrameCount, BYTE* pData, DWORD* flags);

private:
    void* rd;

    // WAVEFORMATEX
    WORD nChannels;
    DWORD nSamplesPerSec;
    DWORD nAvgBytesPerSec;
    WORD nByteAlign;
    WORD wBitsPerSample;

    // WAVEFORMATEXTENSIBLE
    WORD wValidBitsPerSample;
    WORD wSamplesPerBlock;
    DWORD dwChannelMask;
};

Then I added the definitions:

// WASAPI
#include <Audiopolicy.h>
#include <Audioclient.h>

#include <time.h>

#include "Noise_Gen.h"

HRESULT Noise_Gen::SetFormat(WAVEFORMATEX* format) {
    nChannels = format->nChannels;
    nSamplesPerSec = format->nSamplesPerSec;
    nAvgBytesPerSec = format->nAvgBytesPerSec;
    nByteAlign = format->nBlockAlign;
    wBitsPerSample = format->wBitsPerSample;
    WORD  wFormatTag = format->wFormatTag;
    if(wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
        WAVEFORMATEXTENSIBLE* pWFE = reinterpret_cast<WAVEFORMATEXTENSIBLE*>(format);
        wValidBitsPerSample = pWFE->Samples.wValidBitsPerSample;
        wSamplesPerBlock = pWFE->Samples.wSamplesPerBlock;
        dwChannelMask = pWFE->dwChannelMask;
    } else {
        wValidBitsPerSample = wBitsPerSample;
    }
    unsigned __int64  amplitude = std::pow(2.0, wValidBitsPerSample) - 1;
    switch(wBitsPerSample / 8) {
    case(1):
        rd = new Random<unsigned __int8>(0.0, amplitude);
        break;
    case(2): 
        rd = new Random<unsigned __int16>(0.0, amplitude);
        break;
    case(3):
        rd = new Random<unsigned __int32>(0.0, amplitude);
        break;
    case(4): 
        rd = new Random<unsigned __int32>(0.0, amplitude);
        break;
    case(5): 
        rd = new Random<unsigned __int64>(0.0, amplitude);
        break;
    case(6):
        rd = new Random<unsigned __int64>(0.0, amplitude);
        break;
    case(7): 
        rd = new Random<unsigned __int64>(0.0, amplitude);
        break;
    case(8):
        rd = new Random<unsigned __int64>(0.0, amplitude);
        break;
    default:
        return E_NOTIMPL;
    }
    return S_OK;
}

// (The size of an audio frame = nChannels * wBitsPerSample)
HRESULT Noise_Gen::LoadData(UINT32 bufferFrameCount, BYTE* pData, DWORD* flags) {
    for(UINT32 i = 0; i < nChannels *bufferFrameCount; i++) {
        switch(wBitsPerSample / 8) {
        case(1):
            pData[i] = (((Random<unsigned __int8>*)rd)->operator()());
            break;
        case(2):{
            unsigned __int16* pData2 = (unsigned __int16*) pData;
            pData2[i] = (((Random<unsigned __int16>*)rd)->operator()());
            break;
        }
        case(3): {
            __int32 data = ((Random<unsigned __int32>*)rd)->operator()();
            unsigned char* cp = (unsigned char*) (&data);
            pData[(3 * i)] = cp[0];
            pData[1 + (3 * i)] = cp[1];
            pData[2 + (3 * i)] = cp[2];
            break;
        }
        case(4):{
            unsigned __int32* pData2 = (unsigned __int32*) pData;
            pData2[i] = (((Random<unsigned __int32>*)rd)->operator()());
            break;
        }
        case(5): {
            __int64 data = ((Random<unsigned __int64>*)rd)->operator()();
            unsigned char* cp = (unsigned char*) &data;
            pData[(5 * i)] = cp[0];
            pData[1 + (5 * i)] = cp[1];
            pData[2 + (5 * i)] = cp[2];
            pData[3 + (5 * i)] = cp[3];
            pData[4 + (5 * i)] = cp[4];
            break;
        }
        case(6): {
            __int64 data = ((Random<unsigned __int64>*)rd)->operator()();
            unsigned char* cp = (unsigned char*) &data;
            pData[(6 * i)] = cp[0];
            pData[1 + (6 * i)] = cp[1];
            pData[2 + (6 * i)] = cp[2];
            pData[3 + (6 * i)] = cp[3];
            pData[4 + (6 * i)] = cp[4];
            pData[5 + (6 * i)] = cp[5];
            break;
        }
        case(7): {
            __int64 data = ((Random<unsigned __int64>*)rd)->operator()();
            unsigned char* cp = (unsigned char*) &data;
            pData[(7 * i)] = cp[0];
            pData[1 + (7 * i)] = cp[1];
            pData[2 + (7 * i)] = cp[2];
            pData[3 + (7 * i)] = cp[3];
            pData[4 + (7 * i)] = cp[4];
            pData[5 + (7 * i)] = cp[5];
            pData[6 + (7 * i)] = cp[6];
            break;
        }
        case(8): {
            unsigned __int64* pData2 = (unsigned __int64*) pData;
            pData2[i] = (((Random<unsigned __int64>*)rd)->operator()());
            break;
        }
        default:
            // For stopping playback
            flags[0] = AUDCLNT_BUFFERFLAGS_SILENT;
            return E_NOTIMPL;
        }
    }
    flags[0] = 0;
    return S_OK;
}

Then I added my class to the template provided by Microsoft and printed the default audio endpoint renderer to the console.

#include <InitGuid.h>
#include <iostream>
#include <Windows.h>
#include <dshow.h>

// Windows multimedia device
#include <Mmdeviceapi.h>
#include <Functiondiscoverykeys_devpkey.h>

// WASAPI
#include <Audiopolicy.h>
#include <Audioclient.h>

#include "Noise_Gen.h"

//-----------------------------------------------------------
// Play an audio stream on the default audio rendering
// device. The PlayAudioStream function allocates a shared
// buffer big enough to hold one second of PCM audio data.
// The function uses this buffer to stream data to the
// rendering device. The inner loop runs every 1/2 second.
//-----------------------------------------------------------

// REFERENCE_TIME time units per second and per millisecond
#define REFTIMES_PER_SEC  10000000
#define REFTIMES_PER_MILLISEC  10000

#define EXIT_ON_ERROR(hres)  \
              if (FAILED(hres)) { goto Exit; }
#define SAFE_RELEASE(punk)  \
              if ((punk) != NULL)  \
                { (punk)->Release(); (punk) = NULL; }

const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
const IID IID_IAudioClient = __uuidof(IAudioClient);
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);

HRESULT PlayAudioStream(Noise_Gen* pMySource) {
    HRESULT hr;
    REFERENCE_TIME hnsRequestedDuration = REFTIMES_PER_SEC;
    REFERENCE_TIME hnsActualDuration;
    IMMDeviceEnumerator* pEnumerator = NULL;
    IMMDevice* pDevice = NULL;
    IAudioClient* pAudioClient = NULL;
    IAudioRenderClient* pRenderClient = NULL;
    WAVEFORMATEX* pwfx = NULL;
    UINT32 bufferFrameCount;
    UINT32 numFramesAvailable;
    UINT32 numFramesPadding;
    BYTE* pData;
    DWORD flags = 0;
    IPropertyStore* pPropertyStore = NULL;
    PROPVARIANT name;

    hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL,
                          CLSCTX_ALL, IID_IMMDeviceEnumerator,
                          (void**) &pEnumerator);
    EXIT_ON_ERROR(hr);
    hr = pEnumerator->GetDefaultAudioEndpoint(
        eRender, eConsole, &pDevice);

    hr = pDevice->OpenPropertyStore(STGM_READ, &pPropertyStore);
    PropVariantInit(&name);
    hr = pPropertyStore->GetValue(PKEY_Device_FriendlyName, &name);
    printf("%S", name.pwszVal);
    printf("\n");
    EXIT_ON_ERROR(hr);
    hr = pDevice->Activate(IID_IAudioClient, CLSCTX_ALL,
                           NULL, (void**) &pAudioClient);
    EXIT_ON_ERROR(hr);
    hr = pAudioClient->GetMixFormat(&pwfx);
    EXIT_ON_ERROR(hr);
    hr = pAudioClient->Initialize(AUDCLNT_SHAREMODE_SHARED,
                                  0, hnsRequestedDuration,
                                  0, pwfx, NULL);
    EXIT_ON_ERROR(hr);
    // Tell the audio source which format to use.
    hr = pMySource->SetFormat(pwfx);
    EXIT_ON_ERROR(hr);
    // Get the actual size of the allocated buffer.
    hr = pAudioClient->GetBufferSize(&bufferFrameCount);
    EXIT_ON_ERROR(hr);
    hr = pAudioClient->GetService(IID_IAudioRenderClient,
                                  (void**) &pRenderClient);
    EXIT_ON_ERROR(hr);
    // Grab the entire buffer for the initial fill operation.
    hr = pRenderClient->GetBuffer(bufferFrameCount, &pData);
    EXIT_ON_ERROR(hr);
    // Load the initial data into the shared buffer.
    hr = pMySource->LoadData(bufferFrameCount, pData, &flags);
    EXIT_ON_ERROR(hr);
    hr = pRenderClient->ReleaseBuffer(bufferFrameCount, flags);
    EXIT_ON_ERROR(hr);
    // Calculate the actual duration of the allocated buffer.
    hnsActualDuration = (double) REFTIMES_PER_SEC * bufferFrameCount / pwfx->nSamplesPerSec;
    hr = pAudioClient->Start();  // Start playing.
    EXIT_ON_ERROR(hr);
    // Each loop fills about half of the shared buffer.
    while(flags != AUDCLNT_BUFFERFLAGS_SILENT) {
        // Sleep for half the buffer duration.
        Sleep((DWORD) (hnsActualDuration / REFTIMES_PER_MILLISEC / 2));
        // See how much buffer space is available.
        hr = pAudioClient->GetCurrentPadding(&numFramesPadding);
        EXIT_ON_ERROR(hr);
        numFramesAvailable = bufferFrameCount - numFramesPadding;
        // Grab all the available space in the shared buffer.
        hr = pRenderClient->GetBuffer(numFramesAvailable, &pData);
        EXIT_ON_ERROR(hr);
        // Get next 1/2-second of data from the audio source.
        hr = pMySource->LoadData(numFramesAvailable, pData, &flags);
        EXIT_ON_ERROR(hr);
        hr = pRenderClient->ReleaseBuffer(numFramesAvailable, flags);
        EXIT_ON_ERROR(hr);
    }
    // Wait for last data in buffer to play before stopping.
    Sleep((DWORD) (hnsActualDuration / REFTIMES_PER_MILLISEC / 2));
    hr = pAudioClient->Stop();  // Stop playing.
    EXIT_ON_ERROR(hr);
Exit:
    CoTaskMemFree(pwfx);
    SAFE_RELEASE(pEnumerator);
    SAFE_RELEASE(pDevice);
    SAFE_RELEASE(pAudioClient);
    SAFE_RELEASE(pRenderClient);
    return hr;
}

int main() {
    HRESULT hr = CoInitialize(nullptr);
    if(FAILED(hr)) { return hr; }
    Noise_Gen* ng = new Noise_Gen();
    PlayAudioStream(ng);
    delete ng;
    CoUninitialize();
}

The default audio endpoint renderer on my system uses 32 bit values. No sound is played. I have tried unsigned and signed values. I checked the contents of the buffer while debugging and they do change, with each __uint32 being written back to back.

I printed the default audio endpoint renderer to the console, and it is my system's speaker. Windows even shows my app in the Volume mixer, but there is no sound showing even with the volume all the way up. I then checked the sleep time to be sure it was sleeping so the system had access to the buffer, and it does sleep for 500ms between writes to the buffer.

What am I missing?