<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pedro Farias on Medium]]></title>
        <description><![CDATA[Stories by Pedro Farias on Medium]]></description>
        <link>https://medium.com/@pedro.barbosarf?source=rss-e819b9cff789------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*t9dSnhDMv2_WUy5p6cINxQ.jpeg</url>
            <title>Stories by Pedro Farias on Medium</title>
            <link>https://medium.com/@pedro.barbosarf?source=rss-e819b9cff789------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 09:32:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pedro.barbosarf/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[C#] Do you know what is a ValueTask?]]></title>
            <link>https://medium.com/@pedro.barbosarf/c-do-you-know-what-is-a-valuetask-43ef64834763?source=rss-e819b9cff789------2</link>
            <guid isPermaLink="false">https://medium.com/p/43ef64834763</guid>
            <dc:creator><![CDATA[Pedro Farias]]></dc:creator>
            <pubDate>Sun, 11 Feb 2024 19:00:56 GMT</pubDate>
            <atom:updated>2024-02-11T19:00:56.138Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*NMzKbLAB1wMiNNmWr1PvqA.jpeg" /></figure><blockquote><strong>IMPORTANT</strong> <br><strong>Do not use ValueTask as the default implementation</strong>; read this guide carefully and only apply it when its use is justified and truly makes sense.</blockquote><p>Despite being a feature introduced in C# 7.0, it is very common for people to still not know what <strong>ValueTask</strong> is, how it lives, and how it feeds 😉. To better explore the benefits that this feature brought to the language and how we can use it to tune applications, let’s first understand how a <strong>Task</strong> is allocated in memory and why, in some situations, unnecessary allocations may occur.</p><p>.NET works with two macro-regions of memory, which are known as:</p><ul><li><strong>Stack</strong>: It is composed of a set of <strong>stack frames</strong>, which are essentially the stacking of method calls in a chain, containing the allocation of their parameters, local variables, and their return if any. When a method returns, its entire stack frame is destroyed, automatically releasing the memory spaces allocated for its local variables, return value, and arguments. If one of these allocations is of a value type, its content will also be automatically released because it resides at the same memory address as the declaration of its type; if it is a reference type, the pointer will be deallocated, but the content to which it points (referenced object) will continue to live in the heap.</li><li><strong>Heap</strong>: This is where referenced objects reside, meaning the contents of reference types (classes, strings, interfaces, etc.). This category has the characteristic that the same object can be used in more than one location in the application, so it would not make sense to destroy it when one of these scopes that uses it comes to an end. Imagine that you call 2 methods in parallel passing the same object as an argument; when the first one returns its result, would it make sense to destroy the referenced object? No, because it may still be in use by the second method. Due to this situation, this object will remain alive in the heap, and in each cycle of the Garbage Collector’s execution, it will analyze which objects still have references to keep alive and which ones are no longer referenced, and can therefore be discarded.</li></ul><p>That said, the stack is an unmanaged area, and therefore, it has some <strong>advantages</strong>:</p><ul><li>Memory is automatically released at the end of the function’s execution.</li><li>Access is very fast because it involves only pointer displacements on the stack.</li><li>The allocation process is managed effectively by the CPU to avoid memory fragmentation.</li><li>It only contains local variables.</li></ul><p>Meanwhile, the heap, although necessary, has some <strong>disadvantages</strong>:</p><ul><li>As it is not an ordered allocation process, the runtime needs to look for idle spaces that can accommodate the object to be allocated, and it is not just a pointer increment that will do this job.</li><li>Managed by the GC, there will be processing costs, as, in addition to periodically analyzing all reference types allocated in memory, the GC makes copies of these objects when they are <a href="https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals#generations">promoted to a higher generation</a> in the heap.</li><li>Fragments memory, requiring the GC to perform a compaction/defragmentation process at the end of each execution cycle.</li></ul><p>When we have an asynchronous function with a <strong>Task&lt;T&gt;</strong> return, we know that this return will be allocated in the heap, as Task is a class, which implies dealing with the mentioned disadvantages with each call. On the one hand, it is fair, as the use of Task can deliver a lot of flexibility and abstraction when we are in an asynchronous execution environment, and this naturally has to have a cost. On the other hand, not always a method with a Task&lt;T&gt; return actually performs an asynchronous operation behind the scenes. And there we have room for optimizations.</p><p>To avoid these allocations in synchronous flows, <strong>ValueTask</strong> was introduced. This abstraction is a <strong>structure</strong>, unlike Task, which is a class. And structures, in C#, are <strong>value types</strong> whose allocation is done directly on the stack.</p><p>This structure has 2 special internal fields, one of them serves to store a generic value T if the execution is synchronous, and the other to store a Task&lt;T&gt; if the execution is asynchronous. The filling of these fields is automatic and mutually exclusive. If we have a result obtained synchronously, it will be stored in the generic T field, and the Task&lt;T&gt; type field will be null, while in an asynchronous situation, Task&lt;T&gt; will be filled, and the value T will be the default value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/869b8e0e307820a1d8a22cd92e93767d/href">https://medium.com/media/869b8e0e307820a1d8a22cd92e93767d/href</a></iframe><h3>Application in a Real Scenario</h3><p>There are scenarios where 99% of the time synchronous operations are executed, and only 1% of the time we would need to resort to an asynchronous code snippet. This type of scenario is quite common when working with the concept of cache.</p><p>In this example, if the application is running for the first time, it will execute the asynchronous path since it will need to query the database. In subsequent executions that seek the same ID, as it will be stored in the cache, there is no need to perform an asynchronous operation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9535fce51352092f68b4681369f7a522/href">https://medium.com/media/9535fce51352092f68b4681369f7a522/href</a></iframe><blockquote><em>Asynchronous operations occur when there is blocking, which is when a thread waits for the execution of a time-consuming operation and becomes idle. Blocking usually occurs when external requests are made, accessing a database, or when there is a heavy workload on the CPU. </em><a href="https://learn.microsoft.com/pt-br/dotnet/csharp/asynchronous-programming/#recognize-cpu-bound-and-io-bound-work"><em>Read more</em></a></blockquote><p>We can notice that the mere presence of an ‘await’ keyword within the method makes the method must be signed with the ‘async’ keyword and return a Task or Task&lt;T&gt;, even if under the hood, the runtime executes it synchronously. This implies that all its executions will be allocated in the heap, regardless of whether it was a synchronous or asynchronous execution. But we can change this behavior to be more dynamic; for that, simply change the return to ValueTask&lt;T&gt;.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0830bd25999d182ccd14cdbad6aac22f/href">https://medium.com/media/0830bd25999d182ccd14cdbad6aac22f/href</a></iframe><p>With this change, all results obtained through the synchronous path will have their value/reference stored directly on the stack. This will generate memory allocation savings in the heap and, consequently, lower processing pressure on the GC.</p><p>Another advantage, resulting from the first, is that with the use of Task&lt;T&gt; (where T is a reference type), both the reference (pointer) and the referenced object are allocated in the heap. After the GC execution cycle has cleared the reference, it would still take another cycle for it to finally realize that the referenced object no longer has references, leading to an unnecessary promotion process in the heap. In the case of ValueTask, this does not happen because the reference will always be on the stack, and the referenced object will be in the heap. Only the latter will depend on the GC to be collected.</p><p>The gain may be subtle in a single execution, but it makes a significant difference if it is called repeatedly over time. This type of performance care is advisable, especially for high-performance systems and for building shared libraries with the community, where we do not know the level of performance demand for applications that will consume them.</p><h3>Other Applications</h3><p>Another example of application is when working with the abstract class Stream; it represents a sequence of bytes and has various types of operations on them, such as writing, reading, asynchronous writing, asynchronous reading…</p><p>One of the concrete classes that inherits from Stream is called MemoryStream, which, as the name suggests, deals with reading and writing data in memory. In this scenario, all calls will be executed synchronously because it involves data in memory. However, when we use polymorphism and do not know the concrete type being assigned to a variable of type Stream, we do not know whether to call Read() or ReadAsync(). To solve this problem, Microsoft changed the return of the method to ValueTask, which facilitates because we can always await it without causing allocation losses for the application.</p><p>Another application where we see the use of ValueTask is when implementing the <a href="https://learn.microsoft.com/pt-br/dotnet/api/system.iasyncdisposable?view=net-8.0">IAsyncDisposable</a> interface. Microsoft preferred to change the return from Task to ValueTask for the DisposeAsync() method because it is a resource release method, which in many cases involves memory, and it is called internally by the runtime itself, which naturally respects the restrictions for using ValueTask, avoiding the risk of being used incorrectly.</p><h3>Drawbacks</h3><p>But as not everything is perfect, the use of <strong>ValueTask</strong> has some disadvantages. It has a simpler mechanism of operation and does not provide some functionalities that a regular Task could provide:</p><ul><li>A ValueTask can only be awaited once, so it is not recommended to store it in a variable without awaiting it first.</li><li>It is not possible to use the combination operation between several ValueTasks. Example: Task.WhenAll(...valueTasks) <strong>is not possible</strong>.</li><li>It is highly discouraged to use .GetAwaiter().GetResult() while the operation is still unfinished. Note: If it is necessary to use some restricted functionalities listed above, it is possible to convert a ValueTask into a Task at any time through the .AsTask() method.</li></ul><p><strong>Note</strong>: If it is necessary to use some restricted functionalities listed above, it is possible to convert a ValueTask into a Task at any time through the .AsTask() method.</p><h3><strong>Bottom line</strong></h3><p>The use of ValueTask is increasingly being discussed by the community, and its adoption is becoming more common, just like the use of structure-based components. The official recommendation is still to start implementing an asynchronous operation using Task and only after running benchmarks demonstrating real gains, use ValueTask because sometimes it is not worth the risk of implementing it incorrectly or losing certain flexibilities that a Task can provide.</p><p>Overall, this tool has a simple usage and can save a lot of memory in your application if applied correctly.</p><p>I hope you enjoyed the shared knowledge, and if you have any questions, please leave a comment below, and I will respond soon! 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43ef64834763" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[C#][PT] Você sabe o que é ValueTask?]]></title>
            <link>https://medium.com/@pedro.barbosarf/c-voc%C3%AA-sabe-o-que-%C3%A9-valuetask-511a2cc96c08?source=rss-e819b9cff789------2</link>
            <guid isPermaLink="false">https://medium.com/p/511a2cc96c08</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[asynchronous]]></category>
            <dc:creator><![CDATA[Pedro Farias]]></dc:creator>
            <pubDate>Wed, 19 May 2021 12:35:54 GMT</pubDate>
            <atom:updated>2024-02-03T23:25:30.192Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OC660doohhe1cRDujXES0Q.png" /></figure><blockquote><strong>IMPORTANTE<br>Não utilize ValueTask como implementação padrão</strong>, leia atentamente este guia e só aplique quando seu uso for justificado e realmente fizer sentido.</blockquote><p>Apesar de ser uma funcionalidade introduzida no C# 7.0, é muito comum pessoas ainda não saberem o que é <strong><em>ValueTask</em></strong>, como ela vive e como se alimenta 😉. Para explorar melhor os benefícios que essa funcionalidade trouxe para a linguagem e como podemos utilizá-la para &quot;tunar&quot; as nossas aplicações, vamos primeiramente entender melhor como uma <strong><em>Task</em> </strong>é alocada na memória e porque, em algumas situações, podem acontecer alocações desnecessárias.</p><p>O .NET trabalha com 2 macro-regiões da memória, que são conhecidas como:</p><ul><li><strong><em>Stack: </em></strong>É composta por um conjunto de <strong><em>stack frames</em></strong>,<em> </em>que são, essencialmente, o empilhamento de chamadas de métodos em cadeia, contendo a alocação de seus parâmetros, de suas variáveis locais e do seu retorno se houver. Quando um método é retornado, todo o seu <em>stack frame</em> é destruído, liberando automaticamente os espaços de memória alocados para suas váriaveis locais, para o seu retorno e para seus argumentos. Caso uma dessas alocações seja de um tipo de valor, o seu conteúdo também será liberado automaticamente pois ele reside no mesmo endereço de memória que a declaração do seu tipo; caso seja um tipo de referência, o ponteiro será desalocado mas o conteúdo para o qual ele aponta (objeto referenciado) continuará vivo na <em>heap</em>.</li><li><strong><em>Heap:</em></strong> É onde residem os objetos referenciados, ou seja, os conteúdos dos tipos de referência (classes, <em>strings</em>, interfaces, etc.). Essa categoria possui a característica de que um mesmo objeto pode estar sendo utilizado em mais de um local da aplicação e, então, não faria sentido destruí-lo caso um desses escopos que o utiliza chegue ao fim. Imagine que você chame 2 métodos em paralelo passando como argumento o mesmo objeto, quando o primeiro retornar o seu resultado, faria sentido destruirmos o objeto referenciado? Não, porque ele ainda pode estar sendo utilizado pelo segundo método. Por essa situação, este objeto continuará vivo na <em>heap</em>, e a cada ciclo de execução do <em>Garbage Collector, </em>este analisará quais objetos ainda possuem referência para manter vivo e quais já não são mais referenciados, podendo, então, ser descartados.</li></ul><p>Dito isto, a <em>stack </em>é uma área não gerenciada, e por isso possui algumas <strong>vantagens</strong>:</p><ul><li>A memória é liberada automaticamente ao fim da execução da função.</li><li>O acesso é bastante rápido porque envolve apenas deslocamentos de ponteiro na pilha.</li><li>O processo de alocação é gerenciado de maneira eficaz pela <em>CPU</em>, de forma a não fragmentar a memória.</li><li>Possui apenas variáveis locais.</li></ul><p>Enquanto isso a <em>heap</em>, apesar de ser necessária, possui algumas <strong>desvantagens</strong>:</p><ul><li>Por não ser um processo de alocação ordenado, é necessário que o <em>runtime</em> procure espaços ociosos que comportem o objeto que será alocado, e não é somente um incremento de ponteiro que fará esse trabalho.</li><li>Por ser gerenciada pelo<em> GC,</em> haverá custos de processamento, pois além de analisar todos os tipos de referência alocados na memória de forma periódica, o <em>GC </em>efetua cópias destes objetos quando recebem <a href="https://docs.microsoft.com/pt-br/dotnet/standard/garbage-collection/fundamentals#generations">promoção de geração</a> na <em>heap</em>.</li><li>Fragmenta a memória, necessitando que <em>GC </em>faça um processo de compactação/desfragmentação no final de cada ciclo de execução.</li></ul><p>Quando temos uma função assíncrona com retorno <strong><em>Task&lt;T&gt;</em></strong>, sabemos que este retorno será obrigatoriamente alocado na <em>heap, </em>pois a <em>Task </em>é uma classe, o que implica lidar com as desvantagens mencionadas acima a cada chamada. Por um lado é justo, visto que a utilização de <em>Task</em> pode entregar bastante flexibilidade e abstração quando estamos em um ambiente de execução assíncrona e isso naturalmente tem que ter um custo. Por outro lado nem sempre um método com retorno <em>Task&lt;T&gt;</em><strong><em> </em></strong>executa uma operação assíncrona por debaixo dos panos. E aí temos uma brecha para otimizações.</p><p>A fim de evitar essas alocações em fluxos síncronos, foi introduzida a <strong><em>ValueTask</em></strong>. Esta abstração é uma <strong>estrutura</strong>, ao contrário da <em>Task </em>que é uma classe. E estruturas, no C#, são <strong><em>tipos de valor</em></strong> cuja alocação é feita diretamente na <em>stack.</em></p><p>Esta estrutura possui 2 campos internos especiais, um deles serve para armazenar um valor genérico <em>T</em>, caso a execução seja síncrona, e o outro para guardar uma <em>Task&lt;T&gt;</em>, caso a execução seja assíncrona. Os preenchimentos destes campos são automáticos e mutuamente exclusivos. Se temos um resultado obtido de maneira síncrona ele será guardado no campo genérico <em>T</em> e o campo de tipo <em>Task&lt;T&gt;</em> será nulo, enquanto numa situação assíncrona a <em>Task&lt;T&gt; </em>será preenchida e o valor <em>T</em> será o valor <em>default</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa438fe8728dbaf8a20f3520eab661ce/href">https://medium.com/media/aa438fe8728dbaf8a20f3520eab661ce/href</a></iframe><h3>Aplicação em um cenário real</h3><p>Existem cenários em que 99% do tempo são executadas operações síncronas e em apenas 1% da vezes precisaríamos recorrer a um trecho de código assíncrono. Este tipo de cenário é bastante comum quando trabalhamos com o conceito de cache.</p><p>Neste exemplo, caso a aplicação esteja rodando pela primeira vez, ela executará o caminho assíncrono, visto que necessitará recorrer ao banco de dados. Nas próximas execuções que busquem pelo mesmo <em>id</em>, como este estará armazenado em cache, não será necessário executar uma operação assíncrona.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21c898e1fbc30dc412e6f53fdaa37a8e/href">https://medium.com/media/21c898e1fbc30dc412e6f53fdaa37a8e/href</a></iframe><blockquote><em>Operação assíncronas acontecem quando temos </em>blocking<em>, que é quando uma </em>thread <em>aguarda a execução de uma operação demorada e acaba se tornando ociosa. Geralmente o </em>blocking <em>acontece quando são realizadas requisições externas, acesso a banco de dados ou quando há grande carga de trabalho na CPU. </em><a href="https://docs.microsoft.com/pt-br/dotnet/csharp/async#recognize-cpu-bound-and-io-bound-work"><em>Leia mais</em></a></blockquote><p>Podemos reparar que só o fato de existir uma palavra chave <strong><em>await </em></strong>dentro do método já faz com que o método deva ser assinado com a palavra <strong><em>async</em></strong> e retornar uma<em> Task ou Task&lt;T&gt;</em>, mesmo que por debaixo dos panos o <em>runtime</em> o execute de maneira síncrona. Isso implica que, todas as suas execuções o retorno seja alocado na <em>heap,</em> independente de ter sido uma execução síncrona ou assíncrona. Mas podemos alterar esse comportamento para ser mais dinâmico, para isso basta alterar o retorno para <strong><em>ValueTask&lt;T&gt;</em></strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/230bf50b2dd5ddf53eadb3d06c596bef/href">https://medium.com/media/230bf50b2dd5ddf53eadb3d06c596bef/href</a></iframe><p>Com essa mudança, todos os resultados obtidos através do caminho síncrono terá seu valor/ referência armazenada diretamente na <em>stack</em>. Isso gerará uma economia de alocação na <em>heap</em> e, consequentemente, uma menor pressão de processamento no <em>GC</em>.</p><p>Uma outra vantagem, decorrente da primeira, é que com a utilização de <em>Task&lt;T&gt; (</em>onde <em>T</em> é um tipo de referência), tanto a referência (ponteiro) quanto o objeto referenciado estão alocados na <em>heap, </em>e após o ciclo de execução do <em>GC </em>ter limpado a referência, ainda demoraria mais um novo ciclo para que, enfim, o mesmo constatasse que o objeto referenciado não possui mais referências, o que leva a um processo de promoção de geração na <em>heap </em>de modo desnecessário. No caso da <em>ValueTask </em>isto não acontece, pois a referência sempre estará na <em>stack </em>e o objeto referenciado na <em>heap. </em>Somente o segundo dependerá do <em>GC </em>para ser coletado.</p><p>O ganho pode ser sutil em uma execução isolada, porém faz bastante diferença caso ela seja chamada repetidas vezes ao longo do tempo. Esse tipo de cuidado com performance é aconselhável principalmente para sistemas de alto desempenho e a para construção de bibliotecas compartilhadas com a comunidade, onde não sabemos qual será o nível de exigência em relação a performance das aplicações que irão consumí-las.</p><h3>Outras aplicações</h3><p>Um outro exemplo de aplicação é, quando trabalhamos com a classe abstrata <em>Stream, </em>ela representa uma sequência de <em>bytes </em>e possui vários tipos de operações sobre estes, como escrita, leitura, escrita assíncrona, leitura assíncrona…</p><p>Uma das classes concretas que herdam de <em>Stream </em>chama-se<em> MemoryStream, </em>que como o nome já diz, lida com leitura e escrita de dados em memória.</p><p>Neste cenário, todas as chamadas serão executadas de modo síncrono, por se tratar de dados em memória. Porém, quando utilizamos polimorfismo e não sabemos o tipo concreto que está sendo atribuído a uma variável do tipo <em>Stream</em>, não sabemos se devemos chamar <em>Read()</em> ou <em>ReadAsync(). </em>Para resolver esse problema, a Microsoft alterou o retorno do método para <em>ValueTask</em>, o que facilita pois sempre podemos aguardá-la sem gerar prejuízos de alocação para aplicação<em>.</em></p><p>Uma outra aplicação que vemos o uso de <em>ValueTask </em>é quando implementamos a interface <a href="https://docs.microsoft.com/pt-br/dotnet/api/system.iasyncdisposable?view=net-5.0"><em>IAsyncDisposable</em></a>. A Microsoft preferiu trocar o retorno de <em>Task para ValueTask </em>para o método <em>DisposeAsync() </em>pelo fato de ser um método de liberação de recursos, estes que em muitas vezes estão em memória, e é chamado de forma interna pelo próprio <em>runtime, </em>que naturalmente respeitará as restrições para a utilização de <em>ValueTask, </em>não correndo riscos de ser utilizada de forma incorreta.</p><h3>Desvantagens</h3><p>Mas como nem tudo são flores, a utilização de <strong><em>ValueTask</em></strong><em> </em>possui algumas desvantagens. Ela possui um mecanismo mais simples de funcionamento e não fornece algumas funcionalidades que uma <em>Task </em>comum conseguiria fornecer:</p><ul><li>Uma <em>ValueTask </em>só pode ser aguardada apenas 1 vez, portanto não é recomendado armazenar em uma variável sem aguardá-la primeiro.</li><li>Não é possível utilizar operação de combinação entre várias <em>ValueTask</em>.<br>Exemplo: <em>Task.WhenAll(…valuesTasks) </em><strong>não é possível</strong><em>.</em></li><li>É extremamente desencorajado utilizar <em>.GetAwaiter().GetResult()</em> enquanto a operação ainda não estiver finalizada.</li></ul><p><strong>OBS.:</strong> Caso seja necessário utilizar algumas funcionalidades restritas listadas acima, é possível converter uma <em>ValueTask</em> em <em>Task</em> a qualquer momento através do método <em>.AsTask()</em>.</p><h3>Conclusão</h3><p>A utilização de <em>ValueTask </em>vem sendo cada vez mais discutida pela comunidade, e sua adoção está se tornando cada vez mais comum, assim como a utilização de componentes baseados em estruturas. A recomendação oficial ainda é que se comece implementando uma operação assíncrona utilizando <em>Task </em>e somente após rodar <em>benchmarks </em>demonstrando reais ganhos, utilizar <em>ValueTask</em>, pois às vezes não compensa correr o risco de implementá-la de maneira errada ou perder certas flexibilidades que uma <em>Task </em>pode prover.</p><p>No geral esta ferramenta possui uma utilização simples e pode economizar bastante memória em sua aplicação, se aplicada corretamente.</p><p>Espero que tenham gostado do conhecimento compartilhado e, caso tenha ficado alguma dúvida, deixe um comentário abaixo que em breve eu responderei se souber! 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=511a2cc96c08" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>