C# Producer/Consumer setup, Consumer never works if there's a UI?












-1















I am attempting to make a desktop app that collects data for the user and downloads it. I was previously using a rather poor set up that just called an async download as soon as that data was found, but I wanted to move to a producer/consumer setup, as it really cleaned up a lot of my code and reduced the amount of method parameters I had to pass about.



I am using this as an example to go off of (https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/how-to-implement-a-producer-consumer-dataflow-pattern) and that works all fine and great. However, my application also has a UI. This isn't a UI that needs to work while the program is doing it's thing, the UI basically just sets up arguments. I'm happy for it to be locked. It should be. But when I move the items (from that link) like the setting up of the buffer and the consumer.Wait() into a method that's called when a button from the UI is hit (Run Program), the consumer never acts.



Through logging, and using just a barely modified version from that link, the producer will give exactly what I'm expecting, without issue. But it will never get past the consumer.Wait(). It will just sit there. Specifically, it never gets past the "while (await source.OutputAvailableAsync()){". It just gets stuck forever waiting, while I can guarantee items were correctly sent via the target.Post().



I have a guess that this has to do with maybe not having enough threads available or something? Like the consumer just gets starved? I'm not sure. All I've been able to find are people who want interactive UI's, which I definitely don't. But it seems like my UI and the consumer compete. If I remove the window from appearing in the main method, and just put the main class from that Microsoft documentation, it has no issues at all. I'm just lost as to how to get past.



Edit: My code, though very messy as I try to figure this out, before switching it back over to it's long term solution.



private static void Produce(ITargetBlock<KeyValuePair<string, string>> target)
{

// In a loop, fill a buffer with random data and
// post the buffer to the target block.
for (var i = 0; i < 100; i++)
{
// Create an array to hold random byte data.
var buffer = new KeyValuePair<string, string>(DateTime.Now.ToString("yyyy-M-d") + " profile",
"http://www.orseu-concours.com/451-615-thickbox/selor-test-de-raisonnement-abstrait-niveau-a.jpg");

// Post the result to the message block.
target.Post(buffer);
Console.WriteLine(buffer);
}

// Set the target to the completed state to signal to the consumer
// that no more data will be available.
target.Complete();
}

// Demonstrates the consumption end of the producer and consumer pattern.
private static async Task<int> ConsumeAsync(ISourceBlock<KeyValuePair<string, string>> source)
{
// Initialize a counter to track the number of bytes that are processed.
var line = 0;

// Read from the source buffer until the source buffer has no
// available output data.
while (await source.OutputAvailableAsync())
{
var data = source.Receive();
Console.WriteLine(line + " Data received: " + data);
line++;

// Increment the count of bytes received.
// bytesProcessed += data.Length;
}

return line;
}

public static void SetUp(string targetAccount, bool headless, bool firefoxProfile)
{

var buffer = new BufferBlock<KeyValuePair<string, string>>();
Console.WriteLine("Buffer block creation has no issues");

// Start the consumer. The Consume method runs asynchronously.
var consumer = ConsumeAsync(buffer);
Console.WriteLine("Creating consumer has no issues");

// Post source data to the dataflow block.
Produce(buffer);
Console.WriteLine("Running producer has no issues");

// Wait for the consumer to process all data.
consumer.Wait();
Console.WriteLine("Waiting for consumer to finish has no issues");

// Print the count of bytes processed to the console.
Console.WriteLine("Processed {0} bytes.", consumer.Result);
}









share|improve this question




















  • 1





    In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code

    – Peter Bons
    Jan 1 at 5:44













  • @PeterBons Sorry, avoided posting my code because it was a mess of trial and error messages. The method "SetUp" is called from my UI, when the "Run Program" is pressed. There's normally much more in there, but it's irrelevant to the issue. just different handlers for the arguments. Changing the ".wait" to await, as you suggested, clears up the block, however, it still doesn't operate in the background, as I'm assuming it should be doing. In my real setup, I have it download files, but it doesn't seem like the consumer even starts until it reaches the "await consumer/ consumer.Wait()" point.

    – Devildude4427
    Jan 1 at 6:17













  • @PeterBons Never mind I guess, It seems like my files are just downloaded and cached or something, as they will only appear in the file browser once the "await consumer" is reached. Once that point it reached though, they appear instantly, so I assume it's just a background download. So your initial suggestion worked brilliantly. Thank you so much.

    – Devildude4427
    Jan 1 at 7:23











  • Your welcome. Best wishes and happy coding :-)

    – Peter Bons
    Jan 1 at 7:31
















-1















I am attempting to make a desktop app that collects data for the user and downloads it. I was previously using a rather poor set up that just called an async download as soon as that data was found, but I wanted to move to a producer/consumer setup, as it really cleaned up a lot of my code and reduced the amount of method parameters I had to pass about.



I am using this as an example to go off of (https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/how-to-implement-a-producer-consumer-dataflow-pattern) and that works all fine and great. However, my application also has a UI. This isn't a UI that needs to work while the program is doing it's thing, the UI basically just sets up arguments. I'm happy for it to be locked. It should be. But when I move the items (from that link) like the setting up of the buffer and the consumer.Wait() into a method that's called when a button from the UI is hit (Run Program), the consumer never acts.



Through logging, and using just a barely modified version from that link, the producer will give exactly what I'm expecting, without issue. But it will never get past the consumer.Wait(). It will just sit there. Specifically, it never gets past the "while (await source.OutputAvailableAsync()){". It just gets stuck forever waiting, while I can guarantee items were correctly sent via the target.Post().



I have a guess that this has to do with maybe not having enough threads available or something? Like the consumer just gets starved? I'm not sure. All I've been able to find are people who want interactive UI's, which I definitely don't. But it seems like my UI and the consumer compete. If I remove the window from appearing in the main method, and just put the main class from that Microsoft documentation, it has no issues at all. I'm just lost as to how to get past.



Edit: My code, though very messy as I try to figure this out, before switching it back over to it's long term solution.



private static void Produce(ITargetBlock<KeyValuePair<string, string>> target)
{

// In a loop, fill a buffer with random data and
// post the buffer to the target block.
for (var i = 0; i < 100; i++)
{
// Create an array to hold random byte data.
var buffer = new KeyValuePair<string, string>(DateTime.Now.ToString("yyyy-M-d") + " profile",
"http://www.orseu-concours.com/451-615-thickbox/selor-test-de-raisonnement-abstrait-niveau-a.jpg");

// Post the result to the message block.
target.Post(buffer);
Console.WriteLine(buffer);
}

// Set the target to the completed state to signal to the consumer
// that no more data will be available.
target.Complete();
}

// Demonstrates the consumption end of the producer and consumer pattern.
private static async Task<int> ConsumeAsync(ISourceBlock<KeyValuePair<string, string>> source)
{
// Initialize a counter to track the number of bytes that are processed.
var line = 0;

// Read from the source buffer until the source buffer has no
// available output data.
while (await source.OutputAvailableAsync())
{
var data = source.Receive();
Console.WriteLine(line + " Data received: " + data);
line++;

// Increment the count of bytes received.
// bytesProcessed += data.Length;
}

return line;
}

public static void SetUp(string targetAccount, bool headless, bool firefoxProfile)
{

var buffer = new BufferBlock<KeyValuePair<string, string>>();
Console.WriteLine("Buffer block creation has no issues");

// Start the consumer. The Consume method runs asynchronously.
var consumer = ConsumeAsync(buffer);
Console.WriteLine("Creating consumer has no issues");

// Post source data to the dataflow block.
Produce(buffer);
Console.WriteLine("Running producer has no issues");

// Wait for the consumer to process all data.
consumer.Wait();
Console.WriteLine("Waiting for consumer to finish has no issues");

// Print the count of bytes processed to the console.
Console.WriteLine("Processed {0} bytes.", consumer.Result);
}









share|improve this question




















  • 1





    In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code

    – Peter Bons
    Jan 1 at 5:44













  • @PeterBons Sorry, avoided posting my code because it was a mess of trial and error messages. The method "SetUp" is called from my UI, when the "Run Program" is pressed. There's normally much more in there, but it's irrelevant to the issue. just different handlers for the arguments. Changing the ".wait" to await, as you suggested, clears up the block, however, it still doesn't operate in the background, as I'm assuming it should be doing. In my real setup, I have it download files, but it doesn't seem like the consumer even starts until it reaches the "await consumer/ consumer.Wait()" point.

    – Devildude4427
    Jan 1 at 6:17













  • @PeterBons Never mind I guess, It seems like my files are just downloaded and cached or something, as they will only appear in the file browser once the "await consumer" is reached. Once that point it reached though, they appear instantly, so I assume it's just a background download. So your initial suggestion worked brilliantly. Thank you so much.

    – Devildude4427
    Jan 1 at 7:23











  • Your welcome. Best wishes and happy coding :-)

    – Peter Bons
    Jan 1 at 7:31














-1












-1








-1








I am attempting to make a desktop app that collects data for the user and downloads it. I was previously using a rather poor set up that just called an async download as soon as that data was found, but I wanted to move to a producer/consumer setup, as it really cleaned up a lot of my code and reduced the amount of method parameters I had to pass about.



I am using this as an example to go off of (https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/how-to-implement-a-producer-consumer-dataflow-pattern) and that works all fine and great. However, my application also has a UI. This isn't a UI that needs to work while the program is doing it's thing, the UI basically just sets up arguments. I'm happy for it to be locked. It should be. But when I move the items (from that link) like the setting up of the buffer and the consumer.Wait() into a method that's called when a button from the UI is hit (Run Program), the consumer never acts.



Through logging, and using just a barely modified version from that link, the producer will give exactly what I'm expecting, without issue. But it will never get past the consumer.Wait(). It will just sit there. Specifically, it never gets past the "while (await source.OutputAvailableAsync()){". It just gets stuck forever waiting, while I can guarantee items were correctly sent via the target.Post().



I have a guess that this has to do with maybe not having enough threads available or something? Like the consumer just gets starved? I'm not sure. All I've been able to find are people who want interactive UI's, which I definitely don't. But it seems like my UI and the consumer compete. If I remove the window from appearing in the main method, and just put the main class from that Microsoft documentation, it has no issues at all. I'm just lost as to how to get past.



Edit: My code, though very messy as I try to figure this out, before switching it back over to it's long term solution.



private static void Produce(ITargetBlock<KeyValuePair<string, string>> target)
{

// In a loop, fill a buffer with random data and
// post the buffer to the target block.
for (var i = 0; i < 100; i++)
{
// Create an array to hold random byte data.
var buffer = new KeyValuePair<string, string>(DateTime.Now.ToString("yyyy-M-d") + " profile",
"http://www.orseu-concours.com/451-615-thickbox/selor-test-de-raisonnement-abstrait-niveau-a.jpg");

// Post the result to the message block.
target.Post(buffer);
Console.WriteLine(buffer);
}

// Set the target to the completed state to signal to the consumer
// that no more data will be available.
target.Complete();
}

// Demonstrates the consumption end of the producer and consumer pattern.
private static async Task<int> ConsumeAsync(ISourceBlock<KeyValuePair<string, string>> source)
{
// Initialize a counter to track the number of bytes that are processed.
var line = 0;

// Read from the source buffer until the source buffer has no
// available output data.
while (await source.OutputAvailableAsync())
{
var data = source.Receive();
Console.WriteLine(line + " Data received: " + data);
line++;

// Increment the count of bytes received.
// bytesProcessed += data.Length;
}

return line;
}

public static void SetUp(string targetAccount, bool headless, bool firefoxProfile)
{

var buffer = new BufferBlock<KeyValuePair<string, string>>();
Console.WriteLine("Buffer block creation has no issues");

// Start the consumer. The Consume method runs asynchronously.
var consumer = ConsumeAsync(buffer);
Console.WriteLine("Creating consumer has no issues");

// Post source data to the dataflow block.
Produce(buffer);
Console.WriteLine("Running producer has no issues");

// Wait for the consumer to process all data.
consumer.Wait();
Console.WriteLine("Waiting for consumer to finish has no issues");

// Print the count of bytes processed to the console.
Console.WriteLine("Processed {0} bytes.", consumer.Result);
}









share|improve this question
















I am attempting to make a desktop app that collects data for the user and downloads it. I was previously using a rather poor set up that just called an async download as soon as that data was found, but I wanted to move to a producer/consumer setup, as it really cleaned up a lot of my code and reduced the amount of method parameters I had to pass about.



I am using this as an example to go off of (https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/how-to-implement-a-producer-consumer-dataflow-pattern) and that works all fine and great. However, my application also has a UI. This isn't a UI that needs to work while the program is doing it's thing, the UI basically just sets up arguments. I'm happy for it to be locked. It should be. But when I move the items (from that link) like the setting up of the buffer and the consumer.Wait() into a method that's called when a button from the UI is hit (Run Program), the consumer never acts.



Through logging, and using just a barely modified version from that link, the producer will give exactly what I'm expecting, without issue. But it will never get past the consumer.Wait(). It will just sit there. Specifically, it never gets past the "while (await source.OutputAvailableAsync()){". It just gets stuck forever waiting, while I can guarantee items were correctly sent via the target.Post().



I have a guess that this has to do with maybe not having enough threads available or something? Like the consumer just gets starved? I'm not sure. All I've been able to find are people who want interactive UI's, which I definitely don't. But it seems like my UI and the consumer compete. If I remove the window from appearing in the main method, and just put the main class from that Microsoft documentation, it has no issues at all. I'm just lost as to how to get past.



Edit: My code, though very messy as I try to figure this out, before switching it back over to it's long term solution.



private static void Produce(ITargetBlock<KeyValuePair<string, string>> target)
{

// In a loop, fill a buffer with random data and
// post the buffer to the target block.
for (var i = 0; i < 100; i++)
{
// Create an array to hold random byte data.
var buffer = new KeyValuePair<string, string>(DateTime.Now.ToString("yyyy-M-d") + " profile",
"http://www.orseu-concours.com/451-615-thickbox/selor-test-de-raisonnement-abstrait-niveau-a.jpg");

// Post the result to the message block.
target.Post(buffer);
Console.WriteLine(buffer);
}

// Set the target to the completed state to signal to the consumer
// that no more data will be available.
target.Complete();
}

// Demonstrates the consumption end of the producer and consumer pattern.
private static async Task<int> ConsumeAsync(ISourceBlock<KeyValuePair<string, string>> source)
{
// Initialize a counter to track the number of bytes that are processed.
var line = 0;

// Read from the source buffer until the source buffer has no
// available output data.
while (await source.OutputAvailableAsync())
{
var data = source.Receive();
Console.WriteLine(line + " Data received: " + data);
line++;

// Increment the count of bytes received.
// bytesProcessed += data.Length;
}

return line;
}

public static void SetUp(string targetAccount, bool headless, bool firefoxProfile)
{

var buffer = new BufferBlock<KeyValuePair<string, string>>();
Console.WriteLine("Buffer block creation has no issues");

// Start the consumer. The Consume method runs asynchronously.
var consumer = ConsumeAsync(buffer);
Console.WriteLine("Creating consumer has no issues");

// Post source data to the dataflow block.
Produce(buffer);
Console.WriteLine("Running producer has no issues");

// Wait for the consumer to process all data.
consumer.Wait();
Console.WriteLine("Waiting for consumer to finish has no issues");

// Print the count of bytes processed to the console.
Console.WriteLine("Processed {0} bytes.", consumer.Result);
}






c# producer-consumer






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 6:21







Devildude4427

















asked Jan 1 at 5:40









Devildude4427Devildude4427

168




168








  • 1





    In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code

    – Peter Bons
    Jan 1 at 5:44













  • @PeterBons Sorry, avoided posting my code because it was a mess of trial and error messages. The method "SetUp" is called from my UI, when the "Run Program" is pressed. There's normally much more in there, but it's irrelevant to the issue. just different handlers for the arguments. Changing the ".wait" to await, as you suggested, clears up the block, however, it still doesn't operate in the background, as I'm assuming it should be doing. In my real setup, I have it download files, but it doesn't seem like the consumer even starts until it reaches the "await consumer/ consumer.Wait()" point.

    – Devildude4427
    Jan 1 at 6:17













  • @PeterBons Never mind I guess, It seems like my files are just downloaded and cached or something, as they will only appear in the file browser once the "await consumer" is reached. Once that point it reached though, they appear instantly, so I assume it's just a background download. So your initial suggestion worked brilliantly. Thank you so much.

    – Devildude4427
    Jan 1 at 7:23











  • Your welcome. Best wishes and happy coding :-)

    – Peter Bons
    Jan 1 at 7:31














  • 1





    In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code

    – Peter Bons
    Jan 1 at 5:44













  • @PeterBons Sorry, avoided posting my code because it was a mess of trial and error messages. The method "SetUp" is called from my UI, when the "Run Program" is pressed. There's normally much more in there, but it's irrelevant to the issue. just different handlers for the arguments. Changing the ".wait" to await, as you suggested, clears up the block, however, it still doesn't operate in the background, as I'm assuming it should be doing. In my real setup, I have it download files, but it doesn't seem like the consumer even starts until it reaches the "await consumer/ consumer.Wait()" point.

    – Devildude4427
    Jan 1 at 6:17













  • @PeterBons Never mind I guess, It seems like my files are just downloaded and cached or something, as they will only appear in the file browser once the "await consumer" is reached. Once that point it reached though, they appear instantly, so I assume it's just a background download. So your initial suggestion worked brilliantly. Thank you so much.

    – Devildude4427
    Jan 1 at 7:23











  • Your welcome. Best wishes and happy coding :-)

    – Peter Bons
    Jan 1 at 7:31








1




1





In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code

– Peter Bons
Jan 1 at 5:44







In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code

– Peter Bons
Jan 1 at 5:44















@PeterBons Sorry, avoided posting my code because it was a mess of trial and error messages. The method "SetUp" is called from my UI, when the "Run Program" is pressed. There's normally much more in there, but it's irrelevant to the issue. just different handlers for the arguments. Changing the ".wait" to await, as you suggested, clears up the block, however, it still doesn't operate in the background, as I'm assuming it should be doing. In my real setup, I have it download files, but it doesn't seem like the consumer even starts until it reaches the "await consumer/ consumer.Wait()" point.

– Devildude4427
Jan 1 at 6:17







@PeterBons Sorry, avoided posting my code because it was a mess of trial and error messages. The method "SetUp" is called from my UI, when the "Run Program" is pressed. There's normally much more in there, but it's irrelevant to the issue. just different handlers for the arguments. Changing the ".wait" to await, as you suggested, clears up the block, however, it still doesn't operate in the background, as I'm assuming it should be doing. In my real setup, I have it download files, but it doesn't seem like the consumer even starts until it reaches the "await consumer/ consumer.Wait()" point.

– Devildude4427
Jan 1 at 6:17















@PeterBons Never mind I guess, It seems like my files are just downloaded and cached or something, as they will only appear in the file browser once the "await consumer" is reached. Once that point it reached though, they appear instantly, so I assume it's just a background download. So your initial suggestion worked brilliantly. Thank you so much.

– Devildude4427
Jan 1 at 7:23





@PeterBons Never mind I guess, It seems like my files are just downloaded and cached or something, as they will only appear in the file browser once the "await consumer" is reached. Once that point it reached though, they appear instantly, so I assume it's just a background download. So your initial suggestion worked brilliantly. Thank you so much.

– Devildude4427
Jan 1 at 7:23













Your welcome. Best wishes and happy coding :-)

– Peter Bons
Jan 1 at 7:31





Your welcome. Best wishes and happy coding :-)

– Peter Bons
Jan 1 at 7:31












1 Answer
1






active

oldest

votes


















1















In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code




In case anyone else was stuck like I was, changing the "consumer.Wait()" to "await consumer" as @PeterBons suggested was the answer. In my case it still acts a bit funky, but the full functionality does work, just a bit more behind the scenes than I expected.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993245%2fc-sharp-producer-consumer-setup-consumer-never-works-if-theres-a-ui%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1















    In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code




    In case anyone else was stuck like I was, changing the "consumer.Wait()" to "await consumer" as @PeterBons suggested was the answer. In my case it still acts a bit funky, but the full functionality does work, just a bit more behind the scenes than I expected.






    share|improve this answer




























      1















      In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code




      In case anyone else was stuck like I was, changing the "consumer.Wait()" to "await consumer" as @PeterBons suggested was the answer. In my case it still acts a bit funky, but the full functionality does work, just a bit more behind the scenes than I expected.






      share|improve this answer


























        1












        1








        1








        In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code




        In case anyone else was stuck like I was, changing the "consumer.Wait()" to "await consumer" as @PeterBons suggested was the answer. In my case it still acts a bit funky, but the full functionality does work, just a bit more behind the scenes than I expected.






        share|improve this answer














        In the example a console app is used. They use .wait to make sure the console app does not quit but in your case you should probably await it because .wait is blocking. But please share your actual code. As you might imagine it is kind of hard for us to tell what is going in if you don't post your code




        In case anyone else was stuck like I was, changing the "consumer.Wait()" to "await consumer" as @PeterBons suggested was the answer. In my case it still acts a bit funky, but the full functionality does work, just a bit more behind the scenes than I expected.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 1 at 7:42









        Devildude4427Devildude4427

        168




        168
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993245%2fc-sharp-producer-consumer-setup-consumer-never-works-if-theres-a-ui%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            'app-layout' is not a known element: how to share Component with different Modules