<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Arquivos c# - Adeilson :)</title>
	<atom:link href="https://adeilson.com.br/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>https://adeilson.com.br/tag/c/</link>
	<description>Anotações ao alcance de todos ! ! !</description>
	<lastBuildDate>Tue, 05 Apr 2016 12:10:37 +0000</lastBuildDate>
	<language>pt-BR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
		<item>
		<title>Trabalhar com thread no C# utilizando o TaskFactory</title>
		<link>https://adeilson.com.br/2016/04/05/trabalhar-com-thread-no-c-utilizando-o-taskfactory/</link>
					<comments>https://adeilson.com.br/2016/04/05/trabalhar-com-thread-no-c-utilizando-o-taskfactory/#respond</comments>
		
		<dc:creator><![CDATA[Adeilson]]></dc:creator>
		<pubDate>Tue, 05 Apr 2016 12:08:30 +0000</pubDate>
				<category><![CDATA[Utilitários]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[desenvolvimento]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[visual studio]]></category>
		<guid isPermaLink="false">http://adeilson.com.br/?p=471</guid>

					<description><![CDATA[using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { //var buffer1 = new BlockingCollection&#60;int&#62;(10); //Qtd maxima de 10 na pilha //var buffer2 = new &#8230; <a href="https://adeilson.com.br/2016/04/05/trabalhar-com-thread-no-c-utilizando-o-taskfactory/">Continue lendo <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<pre class="lang:c# decode:true">using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //var buffer1 = new BlockingCollection&lt;int&gt;(10); //Qtd maxima de 10 na pilha
            //var buffer2 = new BlockingCollection&lt;int&gt;(10);
            var buffer1 = new BlockingCollection&lt;int&gt;(); //Sem qtd maxima na pilha
            var buffer2 = new BlockingCollection&lt;int&gt;();

            var f = new TaskFactory(TaskCreationOptions.LongRunning,
                                    TaskContinuationOptions.None);

            //List&lt;Task&gt; t = new List&lt;Task&gt;();
            //t.Add(f.StartNew(() =&gt; CreateInitialRange(buffer1)));

            Task[] tasks = new Task[3];

            //Start the phases of the pipeline
            //Task stage1 = f.StartNew(() =&gt; CreateInitialRange(buffer1));
            //Task stage2 = f.StartNew(() =&gt; DoubleTheRange(buffer1, buffer2));
            //Task stage3 = f.StartNew(() =&gt; WriteResults(buffer2));

            tasks[0] = f.StartNew(() =&gt; CreateInitialRange(buffer1));
            tasks[1] = f.StartNew(() =&gt; DoubleTheRange(buffer1, buffer2));
            tasks[2] = f.StartNew(() =&gt; WriteResults(buffer2));

            //wait for the phases to complete
            //Task.WaitAll(stage1, stage2, stage3);
            Task.WaitAll(tasks);

            Console.WriteLine("Pressione uma tecla...");
            Console.ReadLine();
        }



        static void CreateInitialRange(BlockingCollection&lt;int&gt; output)
        {
            try
            {
                for (int i = 1; i &lt;= 50; i++)
                {
                    Console.WriteLine("Inicio {0}, qtd {1}", i, output.Count());

                    //Console.WriteLine("CreateInitialRange {0}", i);
                    Thread.Sleep(200);
                    output.Add(i);
                }
            }
            finally
            {
                output.CompleteAdding();
            }
        }


        static void DoubleTheRange(BlockingCollection&lt;int&gt; input, BlockingCollection&lt;int&gt; output)
        {
            try
            {
                foreach (var number in input.GetConsumingEnumerable())
                {
                    Console.WriteLine("Meio {0}, qtd input {1}, qtd output {2}", number * number, input.Count(), output.Count());
                    Thread.Sleep(400);
                    output.Add(number * number);
                }
            }
            finally
            {
                output.CompleteAdding();
            }
        }


        static void WriteResults(BlockingCollection&lt;int&gt; input)
        {
            foreach (var squaredNumber in input.GetConsumingEnumerable())
            {
                //Console.WriteLine("Result is {0}", squaredNumber);
                Console.WriteLine("Fim {0}, qtd {1}", squaredNumber, input.Count());
                Thread.Sleep(800);
            }
        }

    }
}</pre>
<p>Fonte: <a href="http://www.codeproject.com/Articles/173340/Task-Parallel-Library-of-n" target="_blank">Link</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://adeilson.com.br/2016/04/05/trabalhar-com-thread-no-c-utilizando-o-taskfactory/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Quebrar arquivo grande em C# (Console)</title>
		<link>https://adeilson.com.br/2015/12/02/quebrar-arquivo-grande-em-c-console/</link>
					<comments>https://adeilson.com.br/2015/12/02/quebrar-arquivo-grande-em-c-console/#respond</comments>
		
		<dc:creator><![CDATA[Adeilson]]></dc:creator>
		<pubDate>Wed, 02 Dec 2015 15:31:36 +0000</pubDate>
				<category><![CDATA[Utilitários]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[desenvolvimento]]></category>
		<guid isPermaLink="false">http://adeilson.com.br/?p=431</guid>

					<description><![CDATA[using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace split { class Program { static void Main(string[] args) { if (args.Length == 2) { string arquivo = args[0]; string destino = args[1]; int qtd = 0; StreamWriter writer &#8230; <a href="https://adeilson.com.br/2015/12/02/quebrar-arquivo-grande-em-c-console/">Continue lendo <span class="meta-nav">&#8594;</span></a>]]></description>
										<content:encoded><![CDATA[<pre class="lang:c# decode:true ">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace split
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length == 2)
            {
                string arquivo = args[0];
                string destino = args[1];
                int qtd = 0;

                StreamWriter writer = null;
                try
                {
                    using (StreamReader inputfile = new System.IO.StreamReader(arquivo))
                    {
                        int count = 0;
                        string line;
                        while ((line = inputfile.ReadLine()) != null)
                        {

                            //800.000 linhas
                            if (writer == null || count &gt;= 800000)
                            {
                                count = 0;
                                if (writer != null)
                                {
                                    writer.Close();
                                    writer = null;
                                }

                                writer = new System.IO.StreamWriter(Path.GetDirectoryName(arquivo) + "\\" + Path.GetFileNameWithoutExtension(arquivo) + "_" + qtd.ToString() + ".txt", true);
                                qtd++;
                            }

                            writer.WriteLine(line.ToLower());

                            ++count;
                        }
                    }
                }
                finally
                {
                    if (writer != null)
                        writer.Close();
                    Console.WriteLine("Split concluido.");
                }
            }
            else
            {
                Console.WriteLine("Split diretorio_e_arquivo diretorio_destino");
            }

            Console.WriteLine("Pressione uma tecla para continuar . . .");
            Console.ReadKey();
        }
    }
}</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://adeilson.com.br/2015/12/02/quebrar-arquivo-grande-em-c-console/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
