All Questions
Tagged with streamwriter multithreading
26
questions
0
votes
2
answers
95
views
Multiple instances of StreamWriter working on multiple different disk files in multiple different tasks. Could I run into threading problems?
I have a C# application that creates multiple tasks (class System.Threading.Tasks.Task).
Each of these tasks writes to a file, each one writes to a different file from the others, using a different ...
2
votes
1
answer
53
views
Forcing an asyncronous call to a c# method to complete before windows switches threads [closed]
I have a project that uses a Parallel.For call to perform the batch modification of files at once since they all take a considerable amount of time and I want to give feedback as the modification ...
0
votes
1
answer
785
views
C# - Issue with lock and StreamWrite (Multi-threading)
I created a simple Logger class that uses StreamWriter to append text to a log file. The main program is a task scheduler that executes tasks asynchronously and writes in the log file if the execution ...
1
vote
1
answer
7k
views
C# - Why I get LockRecursionException when using ReaderWriterLockSlim?
I am working on a multi-threaded program. I'm trying to create a simple logging system with two types of logs: 'INFO' and 'ERROR'.
I created a class called 'Logger' and two static methods: Info and ...
2
votes
0
answers
150
views
One process writes to file, I open it manualy (readonly) , I got exception "The process cannot access the file ..."?
I'm trying to allow just one process be able to write to a file and other processes could only read it , so I tried to open the file by:
sw = new StreamWriter(File.Open(filepath, FileMode.Create, ...
0
votes
1
answer
103
views
The result written to the file does not work as expected
I use multithread to write the result to file. I have 100 results but the number of results saved to the file is only 30 results. What should I do?
public async Task FileWriteAsync(string text)
...
0
votes
0
answers
70
views
Thread logging data to text file - how to?
I tried to build a App that continuously write data in a text file.
I done this with a endless Thread (sleep-write data-sleep...).
Now I recognized, that the app is not continuously running in ...
0
votes
0
answers
68
views
Why StreamWriter.Flush() gives ObjectDisposedExeption here?
This is sort of educational example. Trying to make output.txt like
counter + 0
counter + 1
etc. by writing each line by different thread.
using (StreamWriter output = File.CreateText("output....
-1
votes
1
answer
1k
views
The process cannot access this file because it is being used by another process in c# [duplicate]
I am trying to use 1 lock object and trying to write to the same file using StreamWriter in two different places under the lock but I am getting the error:
The process cannot access the file '...
0
votes
1
answer
2k
views
How to use named Mutex
I'm trying to use Mutex to handle different process/application to write on same file.
This is my code
ILogTest logTest = new LogTest(new FileLog());
logTest.PerformanceTest();
public class ...
0
votes
2
answers
421
views
C# TcpClient - Subsequent calls to StreamWriter only write the first one
I have a TCP connection and a StreamWriter.
public void SendData(string data, TcpClient client)
{
StreamWriter writer = new StreamWriter(client.GetStream());
writer.WriteLine(data);
...
1
vote
2
answers
1k
views
Multi-threading with WebRequest and StreamWriter in VB.NET
I need to make it work in threads for example, thread1 makes call to url with 'order_id=1' and thread2 makes call to url with 'order_id=2' and so on, and the result is then written into the file.
...
2
votes
2
answers
409
views
How to guaranteed write into file in multithreading with exceptions?
This is a simplified example
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
new Thread(() => Method1()).Start();
...
0
votes
1
answer
672
views
Waiting for ThreadPool to finish
I developed an application that saves 10000 lines of lorem ipsum in .txt file on the disk. I used StreamWriter to actually write these lines, and ThreadPool to distribute the computational process to ...
-5
votes
1
answer
236
views
How to run 2 StreamWriters in parallel [closed]
Recently I was working on a project to write a csv file and an XML file at the same time.
They contain the same metadata information, how to open two StreamWriters in C# at the same time?