Baran Topal

Categories


Technology

capture 2 keys in C#.NET

Long ago, I needed to capture 2 keys, shift and F5 keys during debugging for C# in VS 2010 and the following code: if(e.Shift && e.KeyCode == Keys.F5) However, no matter how fast or slow I pressed, the above statement will not be true. Since key events are received one at a time, if you pressed 10 keys at once they would be [...]

baranbaran

Producer & Consumer in Java and .NET

Well, this snippet is from my old backup and let’s have a look for producer-consumer paradigm in action (in Java and .NET): Have a look how join works in Java: http://www.barantopal.com/technology/multithreading-and-join/ import java.util.Stack; import java.util.concurrent.atomic.AtomicInteger; /** * 1 producer and 3 consumers [...]

baranbaran

Some garbage collection in .NET

Well, for garbage collection, I can say that it is a mechanism that objects are marked for destruction when no pointers are pointing to it (Num of references is 0). If you exit the scope of where the object was defined and you didn’t give any other object a pointer to that object then it is marked for destruction. GC is an [...]

baranbaran

some inner join

Say, I am having 2 tables, and in the 1st table, there is an ID and a age and in the 2nd table, there is a age, tallness, and if the first table’s age is equal to this tallness, the age in the second table should be searched in the first table’s age values and if not found, that row in the second table should be deleted. Here [...]

baranbaran

Regex.Replace

Say we have the following string source and want to replace a substring. string source = "I am researching searchlights"; Regex.Replace(source, @"(?\w*)search(?\w*)", @"${wc1}pair${wc2}"); source.Replace("search", "pair"); Both of them will return: I am repairing pairlights If you are going to use Regex technique for a long text (longer [...]

baranbaran

XML Schema Definition

This post will grow later on but let’s start from the definition of XML Schema Definition. The xsd is a XML Schema Definition file, which is used to validate XML or generate DOM classes (through the Xsd.exe Tool, for example).  The Xsd.exe /dataset option generates a class derived from DataSet that corresponds to the specified [...]

baranbaran

File transfer over LAN and WAN in C#

Here is another gem in C#. I need to test this though 🙂 //Client side using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Sockets; using System.IO; namespace ClientServer { //FILE TRANSFER USING C#.NET SOCKET - CLIENT class Program { static void Main(string[] args) { try { [...]

baranbaran