6
votes
0answers
58 views

Detecting UI Thread Hanging and Logging Stacktrace

I have an application that needs to always be responsive. I've written a class that is designed to monitor the UI thread. The goal is to provide useful information in the logs to be able to understand ...
1
vote
0answers
50 views

Thread-safe IDisposable Tcp Connection Manager

I'm trying to implement a thread-safe Connection Manager. I've split my class in two files, one with TraceMessages and another with the actual implementation. I'm just going to post the file with the ...
3
votes
1answer
99 views

Multithreaded C# TCP Socket Server

I am trying to write a simple TCP server in C#. It needs to be able to receive packets and do work on them. Ideally it will only be receiving packets from a single computer, but I'm making it able to ...
6
votes
1answer
77 views

Caching a value just once and update it without blocking other threads

I need some advice about my code. The following code will create a new object the first time, and also force other threads to wait for the creation. When the object is created, we return the cached ...
3
votes
1answer
125 views

TCP/IP multithread chat

I'm learning C# and would love to receive some feedback for my code. Server: ...
1
vote
2answers
123 views

Is ThreadPool QueueUserWorkItem best option for handling event? [closed]

I have a WinForms application that has value change event coming from ble device. The event can be hit from more than one device also one device can send a notification to event in every 4 secs. ...
2
votes
1answer
41 views

Thread-safety based on object value

I need to create thread-safety on a Web-API method, but only when two requests containing the same property value are ran simultaneously. I have created a mix of WaitHandles and a ...
0
votes
0answers
62 views

Re-open single instance

I've made a single-instance app using the following code: ...
3
votes
2answers
114 views

Process dependent results of Producer/Consumer queue with explicit locking

I have seen many examples which the results of a Producer/Consumer queue implemented using BlockingCollection<T> are independent, e.g. each result can be ...
2
votes
1answer
68 views

Wait for file method

I've been having problems with a client where the server would move a file on the server, the client would then try and access that file but get a ...
2
votes
1answer
54 views

Read characters slowly (Threading with delay, .NET Framework 2.0)

Couple of months ago I was asked to develop a console app to do the following: Write an application that takes an array of ICharacterReader interfaces, accesses them in parallel, and outputs a ...
3
votes
2answers
74 views

Static ConcurrentDictionary to maintain static objects

I am using following code to maintain some static information. The problem I see with it is that, if the information retrieved using GeKeysFromCache is modified without using lock keyword it may lead ...
1
vote
1answer
83 views

Player Packet System

I have recently coded a system where an instance of class Player is created for each connected socket, once the player class has been created, in its constructor the Socket that connected starts ...
2
votes
1answer
69 views

Read bytes array from file, process and write to another file using multithreading

I was trying to read data from a file and after processing data write it to another file. Reading and writing do not need much CPU time, so I think it would be better if I use multithreading and ...
2
votes
2answers
96 views

Custom log4net raising application-level events

Use Case: I have a form application in which I log events to a file/database and have a need to also raise those events to the application itself (for display purposes). Think old school updating ...
5
votes
1answer
94 views

Single-thread worker in multi-thread webservice

There is standalone WCF webservice, which is providing methods to interact with legacy ERP system. This system exposes an API, which allow programmer to interact with it. The problem is that, for ...
3
votes
2answers
101 views

My first attempt at multithreading in C# with Prime Numbers

This is my first attempt at multithreading in C#. This entire program does several things with prime numbers, but the part I'm going to post is mainly focused with printing out all prime numbers ...
6
votes
1answer
190 views

RabbitMQ wrapper to work in a concurrent environment

I'm developing a common library for my organisation that will be used across different services by different teams. The library is a simple wrapper for RabbitMQ. Some services will only be producers, ...
4
votes
6answers
632 views

Loop for periodic processing in a background thread

Occasionally I need to implement periodic checks in a loop in a background thread, a typical example being asynchronous processing using a message queue. While it’s not terribly complicated, I wonder ...
6
votes
2answers
677 views

Creating multiple threads to process items in a listview

The goal is to pick items from a listview, do some web related task with the information and then update the UI with the returned information from the web request. The problem is with having multiple ...
5
votes
1answer
66 views

Collection to hold maximum number of running Tasks

I need a collection/bag (something) that will hold some maximum number of running Task objects. Adding a new running Task to the ...
6
votes
2answers
71 views

Synchronization of transaction processing

There's a server which does the following: Receive request with transaction id Load corresponding transaction from storage. New transaction object is returned each time Process transaction Save ...
6
votes
1answer
133 views

Clicking game in windows forms

I've made a simple clicking game where you spam a button in order to get coins which you can use to buy upgrades to get even more coins. I've only 2 classes one that is responsible for the game logic ...
5
votes
1answer
99 views

Send multiple individualised emails via a limited number of SMTP clients

This is my first foray into multi-threading, and I'm keen to know if I have fallen into any traps or have room for optimisation/improvement. Example usage: ...
5
votes
1answer
65 views

Working with threads - shared access and graceful cancellation

I've created this program to show how to stop threads in a controlled manner. Important points in the program: Starting and waiting for threads Exception handling Stopping threads in a controlled ...
5
votes
2answers
883 views

Faster brute force algorithm

I have this brute force code, where you input a password and runs through combinations of numbers, lowercase and uppercase letters, and special characters until it match the password given. The ...
1
vote
1answer
41 views

Simplify TcpListener application in C#

I have a simple application that can receive and send tcp data. right now there's a thread used to start the listener and within this thread there's another thread to receive. it works but it seems ...
2
votes
1answer
366 views

Simple multi-client echo server

I've been looking at some async comms in C#. As a proof of concept, I've written a simple multi-client echo server. The server allows multiple TCP clients to connect and listens for input from the ...
3
votes
4answers
109 views

Optimizing algorithm of analyzing incoming data

I've been making an app, which gets data from external device (via bluetooth) and displays received data. I'm still pretty new to programming and I'm struggling to finish this app. I wrote some code, ...
1
vote
3answers
172 views

Simple scoped lock

I've implemented a simple scoped lock like this: ...
4
votes
1answer
285 views

Read and write in C# buffer in parallel

I have a buffer - int array with defined length. I want to read and write values into this array in parallel. For instance, 5 readers and 3 writers with different ...
5
votes
2answers
131 views

Generic thread-safe data structure

I wrote the following class so that a single object can be shared across many threads. Is using the ReaderWriterLockSlim redundant in this case and only ...
1
vote
2answers
266 views

Using Concurrent Dictionary and Lazy<T> to cache expensive query results and only run query once in a threadsafe manner

Ok, so I'm querying a webservice. This webservice is slow with multiple o's. I want to cache the results of the query, because I only want to query on a given set of parameters once during my ...
4
votes
2answers
179 views

C# multithreading console app

I making simple multithreading signature program (it calculate SHA256 hash for parts of file). Please check my code and I would be grateful if you tell me about errors in my code Program.cs ...
3
votes
1answer
94 views

Deadlock watchdog for shared structures

In our application we have data which needs to be shared between multiple threads. Now and then we ran into a race condition and we could not figure out where that was. So I have implemented a ...
3
votes
0answers
660 views

Blocking TCP Client with Threads vs. Non-Blocking TCP Client with Unitys Update

I'm not sure if this is the right subsite of stackexchange because it's not only about code review but a bit about design eihter. I'm currently developing a network application. I need to connect a (...
5
votes
2answers
113 views

C# ThreadPool inplementation

I have implemented some methods to make the creation of multithreaded programs easier for me in the future The requirement was: Be able to add as many Tasks as I need to the pool Be able to restrict ...
4
votes
1answer
241 views

Consuming chunks from ConcurrentQueue

I need to implement a queue of requests which can be populated from multiple threads. When this queue becomes larger than 1000 completed requests, these requests should be stored into a database. <...
1
vote
1answer
80 views

A class for handling chores

I have created a class which handles (what i call) idle chores. These chores need to be executed every x seconds (x is random every time but within a certain range defined in the settings) With this ...
0
votes
1answer
86 views
4
votes
1answer
2k views

Start an EventHandler in different Thread

I just stumbeled accross some code and I would do it in a different way. Since I am quite new to programming, I just wanted to know if I understand it right. Original Code: ...
3
votes
2answers
369 views

Multi threading with webrequests/responses

I have been working with multi threading and would like some feedback on the code, i generally suck at class design/OO which i am trying to improve. Im sure there is a better way of making it neater ...
7
votes
1answer
137 views

Multithreaded Decompression

I'm working on optimizing a class for decompressing Mass Effect 3's .sfar files. .sfar files are archives, and this function decompresses a file from inside an .sfar and writes it to the provided ...
6
votes
2answers
550 views

First simple multithreaded application

It's been quite some time since I got my eye on the multi-threading, today I decided to create a really simple application which runs 2 while loops simultaneously and prints the current progress of ...
4
votes
2answers
519 views

Passing variable to BackgroundWorker and use the same value later

I create multiple BackgroundWorker within a for-loop and each of them needs to know a special value. To simplify, it is just <...
7
votes
1answer
538 views

Update bitmap in picturebox with data from a socket

I'm working on a screen sharing project, and I receive a small block of images from a Socket constantly. I need to update them on a certain initial desktop bitmap I ...
3
votes
2answers
124 views

Make all additional threads return from a method using Interlocked.Increment

I need to ensure a method is executed only by one thread at a time. Contrary to what most of the synchronization primitives do, I don't need other threads to wait, I want them to return from the ...
7
votes
2answers
847 views

Simple dispatcher implementation

I need a simple dispatcher implementation(invoke methods on one thread from many threads) once you dispatch method curent thread should wait for results, so I'm thinking about something like this: <...
4
votes
3answers
250 views

Exclusive access to objects

Take a look at following code: ...
3
votes
1answer
128 views

Run multiple prerequisite methods in parallel before continuing

I have an application in which I have multiple slow running prerequisite methods I need to call in order to have the data I need to continue. To try to speed this up I am doing this: ...