Monday, March 28, 2022

C API export

C API export

  1. Exporting C Functions for Use in C or C++ Language Executables
  2. If you have functions in a DLL written in C that you want to access from a C language or C++ language module, you should use the __cplusplus preprocessor macro to determine which language is being compiled, and then declare these functions with C linkage if being used from a C++ language module. If you use this technique and provide header files for your DLL, these functions can be used by C and C++ users with no change.

  3. Way to use common class between C style exporting API in C++ DLL
  4. Part II Using the C/C++ API
  5. Example 1a: Set up My API to run an export
  6. Data Export and Import Operations
  7. DLL Export Viewer v1.66
  8. This utility displays the list of all exported functions and their virtual memory addresses for the specified DLL files. You can easily copy the memory address of the desired function, paste it into your debugger, and set a breakpoint for this memory address. When this function is called, the debugger will stop in the beginning of this function. For example: If you want to break each time that a message box is going to be displayed, simply put breakpoints on the memory addresses of message-box functions: MessageBoxA, MessageBoxExA, and MessageBoxIndirectA (or MessageBoxW, MessageBoxExW, and MessageBoxIndirectW in unicode based applications) When one of the message-box functions is called, your debugger should break in the entry point of that function, and then you can look at call stack and go backward into the code that initiated this API call.

  9. Windows 10 DLL File Information 37
  10. Windows 7 DLL File Information
  11. API hooking revealed
  12. The article demonstrates how to build a user mode Win32 API spying system

  13. Win32 API: C++ to .NET
  14. Merits of Anti-Reverse-Engineering for MOGs
  15. Merits of Anti-Reverse-Engineering for MOGs

  16. A Chained Property Observer
  17. Set of utility classes to observe a chain of INotifyPropertyChanged objects.

  18. A UITypeEditor for easy editing of flag enum properties in the property browser
  19. A UITypeEditor for easy editing of flag enum properties in the property browser.

  20. Complex Properties in C#
  21. 'Complex properties' and Size3D in C#.

Events and Delegates

focus on event and delegate

    extremely good posts

  1. Events Made Simple
  2. Events made simple

  3. Delegates and Events
  4. People often find it difficult to see the difference between events and delegates. C# doesn't help matters by allowing you to declare field-like events which are automatically backed by a delegate variable of the same name. This article aims to clarify the matter for you. Another source of confusion is the overloading of the term "delegate". Sometimes it is used to mean a delegate type, and at other times it can be used to mean an instance of a delegate type. I'll use "delegate type" and "delegate instance" to distinguish between them, and "delegate" when talking about the whole topic in a general sense.

  5. Complex Properties in C#
  6. 'Complex properties' and Size3D in C#.

    other good posts

  7. Delegates and Events In C# .NET
  8. In this article, you will learn how to create and manipulate delegate types as well as C# events that streamline the process of working with delegate types.

  9. Events In C#
  10. Events are members of the class that raises them. When some thing happens a class can raise an event, which have a message that contain informations about the event (event arguments) and send them out to the rest of the application, other parts of the application can respond to the event by excuting methods called event handlers.

  11. Advances in .NET Event Handling
  12. In this article we shall discuss the means in which event handlers are executed in .NET applications. This is a very important topic, because most .NET applications are event driven and mistakes and misunderstandings in event handling may cause them to work incorrectly. As will be shown, the order of execution of event handlers may become a major issue in event driven applications, especially when event handlers change the state of the object that has raised the event or changes the contents of the event arguments that are shared among handlers. Due to these interactions, application behavior may become unexpected and unpredictable, leading to errors that are hard to trace when debugging the application.

  13. Event Handling in C#
  14. No GUI application is complete without enabling actions. Even though arranging components is of significant issue, applying actions is also equally important. It is these actions that instruct the program what to do when something happens, like for example Mouse click, Keyboard press etc. Before beginning our discussion let us review how different API's handle events.

  15. Using Property Grid In C#
  16. Are you familiar with the window in Visual Studio .NET that lets you edit all your forms? You know, the one that you wish you could add to all your programs because it has such a cool interface? You know, the Property Window! Well guess what? You can add it to your windows form as part of your design and use it to allow users to edit class properties directly because Microsoft has provided it, they just don't display it initially in the toolbox.The control is called the Property Grid and you have full access to it. Simply right click on the toolbox

  17. A UITypeEditor for easy editing of flag enum properties in the property browser
  18. A UITypeEditor for easy editing of flag enum properties in the property browser.

  19. Creating Property Editors in DesignTime for VS.Net Easily (UITypeEditor Helper)
  20. This is a base class to help easily create UITypeEditors. It is used to edit control properties in a DropDown window or a Modal-Form in design mode in the Visual Studio IDE

  21. Building a custom UITypeEditor
  22. Design Custom Editor For A Property
  23. UITypeEditor Classes
  24. If you are a Custom Control developer, you work hard provide a good design mode experience within Visual Studio.Net. One aspect to that experience is providing UITypeEditors for the Property window which lets the user manipulate your properties. Building a UITypeEditor is not difficult although it always helps to have something to start you out. This package defines two base classes for Drop Down List type UITypeEditors.

  25. C# Property Examples
  26. Asynchronous Method Invocation
  27. How to use .NET to call methods in a non-blocking mode.

    static

  28. Static Class, Singleton and their Side Effects
  29. This article questions the usage of singleton and static class and discusses about ways to avoid them.

  30. Static keyword in C#
  31. static is a modifier in C# which is applicable for the following:

    1. Classes
    2. Variables
    3. Methods
    4. Constructor
    It is also applicable to properties, event, and operators. To create a static member(class, variable, methods, constructor), precede its declaration with the keyword static. When a member is declared static, it can be accessed with the name of its class directly.

  32. Must Remember: 9 Key Concepts to Keyword ‘Static’
  33. Article summarizes some of the key concepts around the keyword ‘Static’ which every developer must remember.

  34. Static Keyword Demystified
  35. This article aims to clear the confusion regarding the use of the static keyword in C#.

  36. Introducing C# 2.0 static classes
  37. A general discussion on C# 2.0 static classes.

  38. Property Acccesor Modifiers
  39. General description of the new property accessor modifiers in C# 2.0.

  40. UML definitions
  41. This article can be used as a glossary of many RUP and UML elemnts

  42. Introducing C# 2.0 Partial Types
  43. A general discussion on C# 2.0 partial types.

  44. Understanding Static Methods and Data
  45. This article may be helpful for beginners of C#

  46. Object-Oriented Static Destructors
  47. In Delphi, there was always available initialization and finalization section for units. But have you ever wondered how to achieve the same using .NET?

  48. Static Interfaces in C#
  49. Introducing a library (distributed as a Nuget package) that is compensating for the lack of static interfaces in C#

  50. Static Members vs Instance Members (Overview)
  51. An overview on how Static and Instance Declaration works

  52. What is the use of static variable in C#? When to use it? Why can't I declare the static variable inside method?
  53. I have searched about static variables in C#, but I am still not getting what its use is. Also, if I try to declare the variable inside the method it will not give me the permission to do this. Why?

  54. Static Constructors (C# Programming Guide)
  55. A static constructor is used to initialize any static data, or to perform a particular action that needs to be performed only once. It is called automatically before the first instance is created or any static members are referenced.

  56. What is the use of static constructors?
  57. Please explain to me the use of static constructor. Why and when would we create a static constructor and is it possible to overload one?

  58. Static Constructor In C# And Its Usages
  59. C# supports two types of constructors, a class constructor (static constructor) and an instance constructor (non-static constructor).

    1. The static constructor for a class executes before any instance of the class is created.
    2. The static constructor for a class executes before any of the static members for the class are referenced.
    3. The static constructor for a class executes after the static field initializers (if any) for the class.
    4. The static constructor for a class executes at most one time during a single program instantiation
    5. A static constructor does not take access modifiers or have parameters.
    6. A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
    7. A static constructor cannot be called directly.
    8. The user has no control on when the static constructor is executed in the program.
    9. A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.

  60. C# | Difference between Static Constructors and Non-Static Constructors
  61. Static constructors are used to initialize the static members of the class and are implicitly called before the creation of the first instance of the class. Non-static constructors are used to initialize the non-static members of the class. Below are the differences between the Static Constructors and Non-Static Constructors.

    1. Overloading: Non-static constructors can be overloaded but not the static constructors. Overloading is done on the parameters criteria. So if you cannot pass the parameters to the Static constructors then we can’t overload it.
    2. Cases in which the constructor will be implicit: Every class except the static class(which contains only static members) always contains an implicit constructor if the user is not defining an explicit constructor. If the class contains any static fields then the static constructors are defined implicitly.

  62. Invoking an overloaded constructor using this keyword in C#
  63. C# provides a powerful keyword known as this keyword and this keyword has many usages. Here we use this keyword to call an overloaded constructor from another constructor.

  64. Private Constructors in C#
  65. Private Constructor is a special instance constructor present in C# language. Basically, private constructors are used in class that contains only static members. The private constructor is always declared by using a private keyword.

  66. C# | Copy Constructor
  67. A constructor that creates an object by copying variables from another object or that copies the data of one object into another object is termed as the Copy Constructor. It is a parameterized constructor that contains a parameter of the same class type. The main use of copy constructor is to initialize a new instance to the values of an existing instance. Normally, C# does not provide a copy constructor for objects, but if you want to create a copy constructor in your program you can create according to your requirement.

  68. C# | Inheritance in Constructors
  69. In C#, both the base class and the derived class can have their own constructor. The constructor of a base class used to instantiate the objects of the base class and the constructor of the derived class used to instantiate the object of the derived class. In inheritance, the derived class inherits all the members(fields, methods) of the base class, but derived class cannot inherit the constructor of the base class because constructors are not the members of the class. Instead of inheriting constructors by the derived class, it is only allowed to invoke the constructor of base class.

  70. Private Constructors (C# Programming Guide)
  71. A private constructor is a special instance constructor. It is generally used in classes that contain static members only. If a class has one or more private constructors and no public constructors, other classes (except nested classes) cannot create instances of this class.

  72. Fun with Singletons in C# 2.0
  73. This article will show you how to create generic singletons that honor all of their properties and at the same time are extensible enough to handle not so obvious scenarios.

  74. Generic Singleton Provider
  75. An article describing how to use Generics to create a singleton provider.

  76. Implementing the Singleton Pattern in C#
  77. This article describes about design pattern namely Singleton Pattern.

  78. Private Constructor - C#
  79. Here, I have described private constructor and its usage in C#. This article will be useful to both beginners and professional C# developers.

Sunday, March 27, 2022

Windows Basics

Windows Basics

  1. Hiding and Showing Forms in C Sharp
  2. When developing a Windows application using C# it is a fairly safe bet to assume that it will consist of multiple forms (otherwise known as windows). It is unlikely, however, that all of those forms will need to be displayed as soon as the application starts up. In fact, it is more likely that most of the forms will remain hidden until the user performs some action that requires a form to be displayed.

  3. NewtonPlus - A Fast Big Number Square Root Function
  4. A Fast square root function for Big Integers and floats. The algorithm uses a variety of new and existing ideas to calculate the square root with greater efficiency and better performance than other algorithms. The performance of this function only starts large numbers above 2^52. It is presented in both Java and C# versions.

  5. Passing Data between Windows Forms
  6. This article provides a simple example of using delegates and events to transfer data between Windows forms. The example provided contains three separate forms; the main form interacts with the other two forms by responding to events generated by instances of the other two forms.

  7. Form appearance effect and notification window
  8. This article contains a form that can be used to give fade in/out effect to any form and specifically to notification/alert windows.

  9. SplashForm - A Splash Window Form
  10. This article is about a class that extends Windows Forms to create splash screens and About dialogs.

  11. Floating point utilites

Thursday, March 24, 2022

Windows Form release mode does not work

Windows Form release mode does not work

  1. Windows Forms Lives On in .NET 6
  2. Windows Forms would like you to know that the reports of its death are greatly exaggerated.

  3. Difference between a Debug and Release build
  4. Debug mode and Release mode are different configurations for building your .Net project. Programmers generally use the Debug mode for debugging step by step their .Net project and select the Release mode for the final build of Assembly file (.dll or .exe).

  5. C# WinForm cannot generate in release mode
  6. Debugging Release Mode Problems
  7. Surviving the Release Version
  8. Why Program works in debug but not release mode
  9. Application can not run if built in Release mode, Debug mode runs fine
  10. C# Winforms Debug build works, Release fails.
  11. Enter "&" symbol into a text Label in Windows Forms?
  12. How would one enter special characters into a Label in C# (Windows Forms)?

Tuesday, March 22, 2022

NLog tutorials

NLog tutorials

  1. About Sentinel
  2. Sentinel is a log viewer (implemented in WPF) with configurable filtering, extracting, and highlighting (foreground/background colours). Custom classifiers allow messages to be parsed and recomposed prior to display. This site is a fork of the original Sentinel project by Ray Hayes

  3. yarseyah / sentinel
  4. Log-viewer with filtering and highlighting

  5. Which is the best viewer for NLog? [closed]
  6. Which is the best viewer for NLog? log2console sentinel

  7. How to NLog (2.1 & 3.1) with VisualStudio 2013
  8. NLog Tutorial - The essential guide for logging from C#
  9. Create file names with DateTime

Monday, March 21, 2022

compile C# source code into DLL

compile C# source code into DLL

  1. Compile DLL using Command Line C# Compiler
  2. Many users know how to create code library using Visual Studio IDE in GUI environment for making code reusable code so that multiple application can use that dll.but here I am writing something by which after reading this article you will be able to compile DLL using just command line C# compiler without opening Visual Studio IDE.

    csc /target:library /out:MyMaths.dll test.cs test2.cs

  3. How to Compile a .dll from a Source Code [IW5M]
  4. This tutorial shows how to make a script for IW5M using Source-Code and compiling it into a .dll file,

  5. How to include source code in dll?
  6. Short version: I want my program to be able to (read-only-)access its own source code during runtime. Is there a way to automatically package the source code into the dll during compilation?

Saturday, March 19, 2022

windows input event

windows form

    Fancy Forms

  1. Fancy Windows Forms
  2. Bring a fresh / cool look and feel to your applications.

  3. Cool Vista-style Menu
  4. Cool Vista style menu in your .NET applications

    Data Transfer between Forms

  5. Sharing data among Windows Forms
  6. In a Windows application, passing values from a secondary form to the main form or share data among several applications (.NET application).

  7. User Input in Windows Forms
  8. Windows Forms includes a user input model based on events that are raised while processing related Windows messages. The topics in this section provide information on mouse and keyboard user input, including code examples that demonstrate how to perform specific tasks.

  9. Application Class
  10. Provides static methods and properties to manage an application, such as methods to start and stop an application, to process Windows messages, and properties to get information about an application. This class cannot be inherited.

    Remarks The Application class has methods to start and stop applications and threads, and to process Windows messages, as follows:

    1. Run starts an application message loop on the current thread and, optionally, makes a form visible.
    2. Exit or ExitThread stops a message loop.
    3. DoEvents processes messages while your program is in a loop.
    4. AddMessageFilter adds a message filter to the application message pump to monitor Windows messages.
    5. IMessageFilter lets you stop an event from being raised or perform special operations before invoking an event handler.
    This class has CurrentCulture and CurrentInputLanguage properties to get or set culture information for the current thread.

  11. Passing Data between Windows Forms
  12. This article provides a simple example of using delegates and events to transfer data between Windows forms. The example provided contains three separate forms; the main form interacts with the other two forms by responding to events generated by instances of the other two forms.

    In order to communicate between the forms, each of forms capable of generating an event contains declarations for a delegate and an event. A delegate may be thought of as a type safe function pointer and delegates are associated with methods that bear the same signature. An event is a device used to notify listening objects that something has happened; events are associated with a delegate when instantiated.

  13. Application.DoEvents Method
  14. Processes all Windows messages currently in the message queue.

    Remarks When you run a Windows Form, it creates the new form, which then waits for events to handle. Each time the form handles an event, it processes all the code associated with that event. All other events wait in the queue. While your code handles the event, your application does not respond. For example, the window does not repaint if another window is dragged on top.

    If you call DoEvents in your code, your application can handle the other events. For example, if you have a form that adds data to a ListBox and add DoEvents to your code, your form repaints when another window is dragged over it. If you remove DoEvents from your code, your form will not repaint until the click event handler of the button is finished executing. For more information on messaging, see User Input in Windows Forms.

  15. Mandelbrot in C# and Windows forms
  16. A project written in C# and Windows forms to interactively explore the Mandelbrot set

  17. Data Binding Concepts in .NET Windows Forms
  18. A detailed look at the concepts involved in data binding and controlling data binding

  19. Progress Bars, Threads, Windows Forms, and You
  20. Using asynchronous progress bars on your form from start to finish

  21. Command Switchboard for Windows Forms
  22. Switchboard component for user interface commands with design time support

  23. Multi threading with Windows Forms
  24. A Windows threaded client and MVC server demonstrating interaction via XML exchange

    Misc.

  25. The key to multi-threaded Windows Forms UI interaction
  26. Teaches how to use the Invoke functionality so that interaction with UI elements can be safely done.

  27. Articles by James T. Johnson (Articles: 14)
  28. lot of good stuff

  29. Popular Courses
  30. Popular with our users in the last month

Wednesday, March 16, 2022

PDF programs for my Report Format

PDF programs for my Report Format

    PDF Format basics

  1. The Great PDF - Revealed
  2. A project to create PDF files using text editor and digitally sign them.

  3. PDF Library for creating PDF with tables and text, in C#
  4. Create PDF files on the fly using this simple library.

  5. Convert a Text File to a PDF File
  6. This article shows how to convert a text file to PDF.

  7. Tutorials on creating PDF files using C# 2.0
  8. Tutorials on creating PDF files using C# (.NET 2.0) and iTextSharp

  9. Convert a Windows Form to PDF
  10. This article shows how to save a Windows Form to a PDF file.

  11. Create PDF from Images using VB.NET
  12. Create PDF from Image files using VB.NET and PDFSharp library.

    Must Read

  13. Gios PDF .NET library
  14. A .NET library for generating impressive PDF reports.

  15. Gios WORD .NET Library (using RTF specification)
  16. A .NET library for generating Word documents (.DOC) using the RTF (Rich Text Format) specification.

  17. Gios WORD .NET Library (using RTF specification)
  18. Good Projects

  19. Home of PDFsharp and MigraDoc Foundation
  20. PDFsharp and MigraDoc Foundation are published Open Source and under the MIT License and are free to use. Read more...

  21. PDF File Writer C# Class Library (Version 2.0.0)
  22. PDF File Writer is a C# .NET class library allowing applications to create PDF files. The code was developed for VS 2022 and .NET6. The latest update is a major upgrade.

    The PDF File Writer C# class library gives .NET applications the ability to produce PDF documents. The library shields the application from the details of the PDF file structure. The library supports: forms, text, images, tables, graphics, barcodes, web links, charts, sticky notes, encryption and more. The article together with the attached source code provides detailed documentation.

  23. Backup Utility implementing Backup Rotation Scheme (Open Source Windows Forms Application in C#)
  24. CopyTree is a Backup Utility implementing Backup Rotation Scheme. It is an open source Windows Forms Application written in C#. The utility was designed to perform backup of critical folders to multiple backup folders.

  25. What is PDFsharp and MigraDoc?¶
  26. MigraDoc is a document generator. It supports almost anything you find in any good word processor. You just add paragraphs, tables, charts, arrange all this in sections, use bookmarks to create links, tables of contents, indexes, etc. MigraDoc will do the layout creating page breaks as needed. MigraDoc will create PDF or RTF documents.

    PDFsharp is a .NET library for processing PDF file. You create PDF pages using drawing routines known from GDI+. Almost anything that can be done with GDI+ will also work with PDFsharp. Only basic text layout is supported by PDFsharp, and page breaks are not created automatically. The same drawing routines can be used for screen, PDF, or meta files.

  27. APIs for Beginners - How to use an API (Full Course / Tutorial)
  28. What is an API? Learn all about APIs (Application Programming Interfaces) in this full tutorial for beginners. You will learn what APIs do, why APIs exist, and the many benefits of APIs. APIs are used all the time in programming and web development so it is important to understand how to use them.

Tuesday, March 15, 2022

delete all files under a folder

  1. Delete all files and subdirectories in a directory with C#
  2. Given a directory, delete all files and subdirectories present in the directory using C#.

    There are two variations to this problem. In the first variation, we delete all files and subdirectories from the specified directory along with the root directory. In the second variation, we delete all files and subdirectories but retain the root directory.

  3. Delete All Files in a Directory in C#
  4. The DirectoryInfo.GetFiles() method in C# gets all the files inside a specified directory. The DirectoryInfo.GetFiles() method takes the path as an argument and returns an array of the FileInfo class objects that contain information about each file in that directory. We can get all the files inside the specified directory with the DirectoryInfo.GetFiles() method and then delete the files with the FileInfo.Delete() method. The following code example shows us how we can delete all the files inside a directory with the DirectoryInfo.GetFiles() and FileInfo.Delete() method in C#.

  5. Directory.Delete Method
  6. Deletes a specified directory, and optionally any subdirectories.

  7. How to Delete a File in C#
  8. he File class in C# provides functionality to work with files. The File.Delete(path) method is used to delete a file in C#. The File.Delete() method takes the full path (absolute path including the file name) of the file to be deleted. If file does not exist, no exception is thrown.

  9. C# delete file if exists and delete all files in folder, with the specified files and folders
  10. There are different deletion methods according to different deletion requirements. If you want to delete all subfolders and files in a folder, you can delete this folder; if you want to delete a specified file or folder in a folder, you have to iterate and delete it.

  11. How to delete all files and folders from a path in C#?
  12. For deleting all the folders and its respective directories we can make us System.IO namespace available in C#. The DirectoryInfo() class provides the details of all sub directories and file in a directory.

  13. How to delete all files and folders in a directory?
  14. Using C#, how can I delete all files and folders from a directory, but still keep the root directory?

Monday, March 14, 2022

threading - basics and application

1023 vs 1000 threads

  1. Threading in Windows Forms
  2. One of the issues which frequently comes up in newsgroups is how to handle threading in a UI. There are two golden rules for Windows Forms:

  3. The Thread Pool and Asynchronous Methods
  4. The point of the thread pool is to avoid creating lots of threads for short tasks. Thread creation isn't particularly cheap, and if you start lots of threads, each doing only just enough work to warrant being run on a different thread in the first place, the cost of creation could significantly hamper performance. The thread pool solves that by having a "pool" of threads which have already been created and are just waiting for work items. When they've finished executing a work item, they then wait for the next one, etc. By default, the thread pool has 25 threads per processor. Note that the thread pool isn't just used for whatever asynchronous calls you make - the .NET framework libraries use it as well, and things can go badly wrong (usually resulting in a deadlock) if all the threads are used and some of them depend on other tasks which are scheduled. (For instance, if one thread is waiting for the results of another work item, but that work item is never run because there are no free threads.) This is a good reason to avoid using the thread pool for particularly long-running tasks. Personally I usually stick to creating a new thread for anything but pretty trivial tasks. If the thread's going to be running for more than a few seconds, the cost of creating the thread is going to be relatively insignificant.

  5. What .NET Threads Are. Part 1
  6. With the advent of multi-core processors, multithreading has become almost indispensable in the development of applications. It is multi-threading that gives significant performance gain when using multiple processor cores.

  7. Ways of creating multi-threaded applications in .NET (Part 2). ThreadPool Class
  8. In Part 1 of this article, we talked about what threads are in .NET. Now, we want to dwell on the methods of background and asynchronous execution of threads in .NET apps.

    These methods have advantages and disadvantages. They are not always convenient to use, but generally, background and asynchronous execution of threads offers wide opportunities in executing separate background threads for both small and long tasks.

  9. The managed thread pool
  10. The System.Threading.ThreadPool class provides your application with a pool of worker threads that are managed by the system, allowing you to concentrate on application tasks rather than thread management. If you have short tasks that require background processing, the managed thread pool is an easy way to take advantage of multiple threads. Use of the thread pool is significantly easier in Framework 4 and later, since you can create Task and Task objects that perform asynchronous tasks on thread pool threads.

  11. ThreadPool Class
  12. Provides a pool of threads that can be used to execute tasks, post work items, process asynchronous I/O, wait on behalf of other threads, and process timers.

  13. ThreadPool max threads
  14. I've got some trouble with .NET's ThreadPool (.NET 4). I've read that by default .NET has a limit of 25 threads per processor, but according to forum posts on SO and on other places, I can increase the limit with the below code.

  15. Understanding thread pools in C#
  16. Take advantage of thread pools to create and use threads on demand and improve the responsiveness of your application

  17. Thread Pool In .NET Core And C#
  18. Creation and destruction of new threads comes with a cost and it affects an application’s performance. Threads can also be blocked or go into sleep or other unresolved states. If your app doesn’t distribute the workload properly, worker threads may spend the majority of their time sleeping. This is where thread pool comes in handy.

  19. Thread Pooling in C#
  20. In this article, I am going to discuss Thread Pool in C# with examples. Please read our previous article where we discussed the Performance Testing of a multithreaded application in C#. As part of this article, we are going to discuss the following pointers.

  21. Performance Testing of a Multithreaded Application
  22. In this article, I am going to discuss the Performance Testing of a multithreaded application in C# with an example. Please read our previous article where we discussed Deadlock in C#. As part of this article, I will show you the performance implications of a multithreaded program when we run the application on a machine having a single core/processor versus a machine multi-core/processor.

  23. How Thread pool works in C#
  24. When a request sent to asp.net application A thread is created to handle the request. When a thread is created, some resources such as memory are allocated to the thread. Finally, when the job is done, Garbage Collector destroys the object created for the thread. The thread life cycle is as follows:

  25. C# THREAD POOLING USING EXAMPLE STEP BY STEP
  26. This article is bit advance version of threading so if you have landed here directly then I would like to request you to read our previous article on Threading and Types of Threading, Here you will understand how to create thread objects and different types of thread methods but if you know threading and particularly looking for this article then continue reading this article.

  27. C# ThreadPool Usage
  28. This C# tutorial shows how to use the ThreadPool type from System.Threading.

  29. C# ThreadPool
  30. Use the ThreadPool type from System.Threading. Create a WaitCallback object.

  31. C# - Threading, Tasks, Async Code and Synchronization Techniques - Part 2
  32. In Part 1 of this small series on Threading, Tasks, Async Code and Synchronization Techniques we talked about:

  33. C# - Threading, Tasks, Async Code and Synchronization Techniques - Part 1
  34. In this small series, we will begin an extremely interesting journey, as we are going to start learning about Threads, Tasks / Parallel Class, Async code and Synchronization Techniques (locks, semaphores etc).

  35. General usage of ThreadPool
  36. The default number of available workers is 1023 and 1000 for asynchronous I/O threads. These values are flexible, so that the developer can dynamically adapt them to the current needs.

    ThreadPool is a .NET implementation of the thread pool pattern. What it does is it allows a number of threads to be run independently in a thread queue for the current application.

  37. C# : UNDERSTANDING THREADS and threadpool
  38. Real world software uses concurrency. As you know concurrency has several advantages, main thing is it simulates several things in one time concept. .NET gives three ways for the developers to achieve concurrency while we write code. They are: 1) Thread 2)ThreadPool 3)Task

  39. Jon Skeet's C# and .NET articles and links
  40. The code in all articles is C#-based, as that's the background I come from. Many of the concepts in the C# articles will be applicable to other .NET languages, but there may be some wrinkles which are C#-specific. The framework articles should be more language-agnostic, even though they are couched in C# terms.

  41. C# ThreadPool class (thread pool)
  42. The CLR thread pool does not create threads immediately when the CLR is initialized. Instead, the thread pool initializes a thread when the application wants to create threads to run tasks

Wednesday, March 9, 2022

asynchronous call

c# delegate begininvoke

  1. Asynchronous Programming Overview
  2. The .NET Framework allows you to call any method asynchronously. Define a delegate with the same signature as the method you want to call; the common language runtime automatically defines BeginInvoke and EndInvoke methods for this delegate, with the appropriate signatures.

  3. Calling Synchronous Methods Asynchronously
  4. .NET enables you to call any method asynchronously. To do this, you define a delegate with the same signature as the method you want to call. The common language runtime automatically defines BeginInvoke and EndInvoke methods for this delegate, with the appropriate signatures.

  5. Call a Method Asynchronously using Delegate BeginInvoke and EndInvoke Pattern
  6. Abstract: In this article, we will explore multiple ways to call a method asynchronously using Delegates. You can call methods asynchronously in four different ways using the BeginInvoke() and EndInvoke() methods of the Delegate class

    In this article, we will explore multiple ways to call a method asynchronously using Delegates. You can call methods asynchronously in four different ways using the BeginInvoke() and EndInvoke() methods of the Delegate class. The four different ways are using the EndInvoke pattern, WaitHandle, Polling pattern and using a Callback Pattern. In this article, we will see the Delegate EndInvoke Pattern. In the subsequent articles, we will explore the Polling Pattern and Callback pattern.

    A delegate is a special method that encapsulates a method and represents a method signature. From the main thread, when a method is invoked using a delegate, the Main thread has to wait until the method, that was invoked, has completed. This could prove expensive if your code is performing a slow operation like downloading a large file from your server.

  7. Difference between delegate.BeginInvoke and using ThreadPool threads in C#
  8. In C# is there any difference between using a delegate to do some work asynchronously (calling BeginInvoke()) and using a ThreadPool thread as shown below

  9. Use BeginInvoke and EndInvoke to perform tasks asynchronously in C#
  10. This example uses the Emboss method to create embossed images. How that method works isn’t important to the discussion of working asynchronously so it isn’t covered here. Download the example to see how it works. The only thing about that method that matters for this discussion is that it is slow so running it on multiple cores or CPUs can save time.

    Good Case Study

  11. BeginInvoke with delegate
  12. I've been doing some reading tonight on async delegate method invocations and I'm not too clear on what's going on under the hood with delegate.BeginInvoke() but I wanted to know if someone can tell me if there are any performance differences between these two code blocks as far as using an AsyncCallback and not using an AsyncCallback and take into consideration that I'm updating the GUI winForm intensively (multiple times per sec):

  13. What's up with BeginInvoke?
  14. Why and when to use Control.BeginInvoke()?

  15. Simple Blocking Queue for Thread Communication and Inter-thread Invocation
  16. A generic class to be used as a conveyor for data and tasks between threads

  17. Asynchronous Delegates
  18. Sometimes it is desirable to call a method asynchronously, so the call returns immediately while the method executes on a separate thread. The runtime provides a standard way that any method can be called asynchronously, taking into account retrieving return values and ref/in parameters supplied to the method. When the C# compiler encounters a delegate, the delegate derived class it generates contains three key methods:

  19. Asynchronous Calls in .NET
  20. When you make a method call on an object, typically you must block the client while the object executes the call, and control returns to the client only when the method completes execution and returns.

  21. Detailed explanation of using Invoke and BeginInvoke in C# form
  22. In the use of Invoke or BeginInvoke, the delegate delegate is used without exception. As for the essence of delegate, please refer to my other essay: Views on .net events .

  23. C: delegate BeginInvoke as asynchronous thread
  24. In an application scenario, the browser uploads a file, and the file background calls for file conversion, which takes quite a long time. In this way, if a thread is synchronized, the user feels stuck on the browser. The card card card card, here we use the entrusted BeginInvoke and endinvoke methods to operate the thread. The BeginInvoke method can use different threads. Step through the method the delegate points to. Then get the return value of the method through the endinvoke method (the return value of the endinvoke method is the return value of the called method), or make sure that the method has been successfully called. To put it plainly, it is equivalent to opening a multithread. After your user file is saved, the response returns. This BeginInvoke asynchronously executes the delegate method. After that, execute your asynchrony callback function. Number;

  25. How to perform C# Asynchronous operations
  26. In this article I will discuss about the different ways in which we can perform a long running operation asynchronously in C#. I will discuss all the cases with examples. This will help you to decide which method you can opt for while working asynchronous programming.

  27. Invoking Methods Asynchronously Using Delegates
  28. Asynchronous operation improves the program responsiveness and availability. In my past article titled Asynchronous Programming In .NET , I explained how to design your components with built-in support for asynchronous operations. But what if some one has already developed the component and that too without asynchronous programming support? In such cases delegates can come to the rescue. In fact that is the topic of this article.

  29. How delegate can be used for callback in c#?what is Asynchronous Delegate?
  30. Consider below example where delegate is pointing to function which is time consuming.

  31. C# – Asynchronous Programming using BeginInvoke
  32. In C#, delegates automatically get the BeginInvoke and EndInvoke methods defined for them. BeginInvoke is used for running the processes defined by the method and assigned to the delegate on a different thread (asynchronously).

    The BeginInvoke method takes a AsyncCallback delegate parameter as a callback method. A common misconception about the BeginInvoke method is that if one does not care about when the method invoked by BeginInvoke completes or its return value, then one can pass in null for this method. THIS IS WRONG! and is partly based on old documentation. If you look at this MSDN document, you can clearly see that the EndInvoke method is not optional but required.

    Good Examples

  33. Delegates And Async Programming
  34. Recall that the .Net delegate type is essentially a type-safe, object oriented, function pointer. Let's get into a bit more detail about it. When you declare a .Net delegate, the C# compiler responds by building a sealed class that derives from the System.MulticastDelegate with the ability to maintain a list of method addresses, all of which may be invoked at a time or a later time.

  35. Delegate And Async Programming C# (AsyncCallback And Object State)
  36. continued post. I'm using the same example as in my previous article, so the following are all the terms and code from the previous example:

  37. Asynchronous Calls in .NET
  38. However, there are quite a few cases where you want to call methods asynchronously?that is, you want control to return immediately to the client while the object executes the called method in the background, and then somehow let the client know when the method execution is completed. Such an execution mode is called asynchronous method invocation and the action is an asynchronous call. Asynchronous calls allow you to improve availability, increase throughput and performance, and make your applications more scalable.

  39. 2 Ways to Implement Asynchronous Technique in C#
  40. 1)Implement by delegate. 2)Using C# 5.0, async and await keyword

    A few days ago in our organization we were trying to implement asynchronous programming (obviously in C# with Visual Studio 2010). First of all Visual Studio 2010 targets the .NET framework 4.0 and asynchronous programming is the concept of C# 5.0 that demands .NET framework 4.5 to compile and run.

  41. What is AsyncCallback?
  42. What is the use of AsyncCallback and why should we use it?

    Demo to pick asynchronous programming quickly

  43. IAsyncResult Interface
  44. very good example to understand IAsyncResult usage.

    Represents the status of an asynchronous operation.

    The following example demonstrates how to use the AsyncWaitHandle property to get a WaitHandle, and how to wait for an asynchronous call on a delegate. The WaitHandle is signaled when the asynchronous call completes, and you can wait for it by calling the WaitOne method.

  45. AsyncResult Class
  46. Encapsulates the results of an asynchronous operation on a delegate.

    Inheritance: Object ->AsyncResult
    Attributes:ComVisibleAttribute
    Implements: IAsyncResult , IMessageSink

  47. Asynchronous Programming Using Delegates
  48. Delegates enable you to call a synchronous method in an asynchronous manner. When you call a delegate synchronously, the Invoke method calls the target method directly on the current thread. If the BeginInvoke method is called, the common language runtime (CLR) queues the request and returns immediately to the caller. The target method is called asynchronously on a thread from the thread pool. The original thread, which submitted the request, is free to continue executing in parallel with the target method. If a callback method has been specified in the call to the BeginInvoke method, the callback method is called when the target method ends. In the callback method, the EndInvoke method obtains the return value and any input/output or output-only parameters. If no callback method is specified when calling BeginInvoke, EndInvoke can be called from the thread that call

  49. Calling Synchronous Methods Asynchronously
  50. Important No matter which technique you use, always call EndInvoke to complete your asynchronous call.

    the same as item 2. it has good examples to show 4 ways to make asynchronous call.

    .NET enables you to call any method asynchronously. To do this, you define a delegate with the same signature as the method you want to call. The common language runtime automatically defines BeginInvoke and EndInvoke methods for this delegate, with the appropriate signatures.

    The code examples in this topic demonstrate four common ways to use BeginInvoke and EndInvoke to make asynchronous calls. After calling BeginInvoke you can do the following:

    1. Do some work and then call EndInvoke to block until the call completes.
    2. Obtain a WaitHandle using the IAsyncResult.AsyncWaitHandle property, use its WaitOne method to block execution until the WaitHandle is signaled, and then call EndInvoke.
    3. Poll the IAsyncResult returned by BeginInvoke to determine when the asynchronous call has completed, and then call EndInvoke.
    4. Pass a delegate for a callback method to BeginInvoke. The method is executed on a ThreadPool thread when the asynchronous call completes. The callback method calls EndInvoke.
  51. Asynchronous Method Invocation
  52. How to use .NET to call methods in a non-blocking mode.

  53. Asynchronous Programming Model (APM)
  54. An asynchronous operation that uses the IAsyncResult design pattern is implemented as two methods named BeginOperationName and EndOperationName that begin and end the asynchronous operation OperationName respectively. For example, the FileStream class provides the BeginRead and EndRead methods to asynchronously read bytes from a file. These methods implement the asynchronous version of the Read method.

  55. What's up with BeginInvoke?
  56. Why and when to use Control.BeginInvoke()?

    You are developing this shiny new multithreaded .NET application that has this spanking new UI. You are done coding and it's time for giving a demo to your boss. And while running the demo, the UI hangs. Just hangs. Damn it, you say, it was working fine on my PC. You go back to your source and try to figure out why that happened. After a lot of poking around/debugging/swearing, you notice that you call this simple property on a control and it never returns. Or sometimes, it returns, but doesn't update the UI correctly. You then read something about calling BeginInvoke. What's that, you wonder. This article will try to answer that. Note that this article will be dealing with the BeginInvoke method on the System.Windows.Forms.Control and not the BeginInvoke method that can be called on delegates to run them asynchronously.

    A warning Control.BeginInvoke, which is what we have been discussing so far, works slightly differently from Delegate.BeginInvoke. Delegate.BeginInvoke grabs a threadpool thread and executes the passed delegate on that thread. Control.BeginInvoke does not use a threadpool thread, it does a PostMessage to the target window handle and returns. This is crucial because if it uses threads, then there is no guarantee to the order in which messages are posted and processed by the application. Also, unlike Delegate.BeginInvoke, Control.BeginInvoke doesn't require every call to BeginInvoke to be matched by an EndInvoke. Of course, if you are using the return value of the method and/or out or ref values, then you need to call it anyway.

  57. Changing a WinForms Control on the 'UI' Thread from another Thread
  58. this.BeginInvo...

  59. Proper Threading in Winforms .NET
  60. Illustrates a simple example of using the Invoke capabilities of Winforms

  61. Towards Cleaner Code II, a C# GUI Invoke/Async Helper
  62. An async helper class in C# with GUI Invoke capability, that greatly reduces the code required to invoke and track tasks that affect forms and controls.

    Misc

  63. Structs in C#
  64. Explains differences between classes and structs, and how to use structs.

  65. File Manager using C# and Multithreading
  66. It helps to maintains files in directories with dynamically generated names using company's naming convention, versions and release

  67. File Splitter Utility in C# - WinForms
  68. Simple File Splitter / Joiner utility that demonstrates FCL and Winforms UI processing

  69. Step by Step Threads
  70. Step by step cross thread communication and thread-safe form control updates.

Wednesday, March 2, 2022

Slide timer & Threading

Slide timer

  1. C# Sliding IN/Out Panel
  2. In this Video We Will Make a Sliding Panel in C# completely from An Empty C# winform Project.

  3. C# WinForm UI - How to make a Sliding IN/OUT Panel
  4. C# Winform Paint
  5. It is a Paint application in C# Winform completely from Scratch.

  6. C# How to Use Paint and the C# Graphics Class to Draw Lines
  7. This video demonstrates how to create a winform application using Visual Studio 2012 (but will also work for 2010, 2008, and 2005). The application built focuses on how to draw lines with C# and use the Graphics classes that are available in .Net. It is intended for beginners looking to create their very first winform application.

  8. C# Drawing Application Tutorial: Part 1
  9. Tutorial on how to make a drawing app using Winforms, Visual Studio, and C#.

  10. Paint Application in C# Visual Studio By Rohit Programming Zone
  11. in this video you will see,How you can create a Paint Application in C# Visual Studio By Rohit Programming Zone

  12. How to create a paint drawing app (Windows Form Application) | C# tutorial | Episode 10
  13. In this video we learn: How to use Bitmap How to use Pen How to use Graphics How to open an image How to save an image

  14. Programming in C#: Learning to Draw (Getting to know the basics)
  15. Learning how the Draw objects is a very useful way of getting to grips with C# programming. We'll be adding Form-elements, events and some basic calculations. Don't worry too much about the variables and calculations, we'll be covering that in our next tutorial.

  16. Create Paint Using C#, Graphics in C#
  17. How to make your own Paint in Visual Studio C# !!!! Easy

  18. Create Paint Using C# - June 04, 2021
  19. How to make your own Paint in Visual Studio C# !!!! Easy

  20. Programming a Tetris Game in C# - Full Guide
  21. Learn how to program a Tetris game in C# using WPF.

  22. How to Create Advanced Tic Tac Toe Game in C#
  23. How to Create a Tic Tac Toe Game in C# Using Windows Forms Application. You will also learn how to add buttons, Labels, and Panels to the C# application. The tutorial includes how to create a function and call the functions within procedures.

    Collapsible Panel

  24. VS2008 Panel
  25. How to make a custom panel control like in Visual Studio 2008 for a Windows Forms Application using the .NET Framework.

  26. The Zen of WinForms Panel Sub-classing
  27. I’ve seen many heroic attempts of sub-classing WinForms Panel control; ranging from simply deriving a new class from Panel and adding the OnPaint event; via trying to hook into WM_NCCALCSIZE; to creating controls hosted inside controls to control the client area. You see, the problem with deriving from Panel is the layouting.

  28. RESX Synchronizer
  29. A tool for synchronizing multilanguage .NET Resource files.

  30. DropDownPanel: a complete Expandable Panel
  31. Useful and simple, it can be used for options pages in your apps.

  32. Expandable panel on all four directions
  33. An expandable panel that you can set to expand/collapse bottom to top, top to bottom, left to right, or right to left.

  34. How to Create a Simple Expandable / Collapsible Panel
  35. How to create a Simple Expandable / Collapsible Menu Panel for Windows Forms in C#.NET

  36. Collapse Panel in C#
  37. Collapse Panel is a usercontrol for using the collapsible panel. There is no more control for collapsing the content in a panel. This control allows you to scroll the contents which are in a panel. We can see the magic of this control by downloading the demo project which is attached with this article.

  38. Why to Build Your Own CSV Parser (or Maybe Not)
  39. Comparison of CSV parsers plus one custom implementation

  40. IDataReader Stub
  41. How to easily mock a data reader

  42. Sliding Timer
  43. How to run an action after a quiet period

  44. Action <T > Delegate
  45. Encapsulates a method that has a single parameter and does not return a value.

  46. Action Delegate
  47. Encapsulates a method that has no parameters and does not return a value.

  48. C# Action
  49. A delegate in C# represents a reference type that encapsulates a method. When we declare a delegate type we specify some parameters and a return type. We can only store those methods in delegates which has same parameters and same return type. Microsoft introduced some pre-built delegates so that we don't have to declare delegates every time. Action is one of the pre-built delegates.

  50. C# | Action Delegate
  51. Action delegate is an in-built generic type delegate. This delegate saves you from defining a custom delegate as shown in the below examples and make your program more readable and optimized. It is defined under System namespace. It can contain minimum 1 and maximum of 16 input parameters and does not contain any output parameter. The Action delegate is generally used for those methods which do not contain any return value, or in other words, Action delegate is used with those methods whose return type is void. It can also contain parameters of the same type or of different types.

  52. => operator (C# reference)
  53. The => token is supported in two forms: as the lambda operator and as a separator of a member name and the member implementation in an expression body definition.

    Lambda expression

  54. Anatomy of the Lambda Expression
  55. C# 3.0(.NET 3.5) introduced the lambda expression along with LINQ. The lambda expression is a shorter way of representing anonymous method using some special syntax.

  56. C# - Anonymous Method
  57. As the name suggests, an anonymous method is a method without a name. Anonymous methods in C# can be defined using the delegate keyword and can be assigned to a variable of delegate type.

  58. C# - Anonymous Method
  59. As the name suggests, an anonymous method is a method without a name. Anonymous methods in C# can be defined using the delegate keyword and can be assigned to a variable of delegate type.

  60. C# - Object Initializer Syntax
  61. C# 3.0 (.NET 3.5) introduced Object Initializer Syntax, a new way to initialize an object of a class or collection. Object initializers allow you to assign values to the fields or properties at the time of creating an object without invoking a constructor.

    BeginInvoke and EndInvoke

  62. Control.Invoke Method
  63. Executes a delegate on the thread that owns the control's underlying window handle.

  64. Control.EndInvoke(IAsyncResult) Method
  65. Retrieves the return value of the asynchronous operation represented by the IAsyncResult passed.

    public object EndInvoke (IAsyncResult asyncResult);

    Remarks If the asynchronous operation has not been completed, this function will block until the result is available.

    NOTE In addition to the InvokeRequired property, there are four methods on a control that are thread safe: Invoke, BeginInvoke, EndInvoke, and CreateGraphics if the handle for the control has already been created. Calling CreateGraphics before the control's handle has been created on a background thread can cause illegal cross thread calls. For all other method calls, you should use one of the invoke methods to marshal the call to the control's thread.

  66. Control.BeginInvoke Method
  67. Executes a delegate asynchronously on the thread that the control's underlying handle was created on.

  68. Calling Synchronous Methods Asynchronously
  69. .NET enables you to call any method asynchronously. To do this, you define a delegate with the same signature as the method you want to call. The common language runtime automatically defines BeginInvoke and EndInvoke methods for this delegate, with the appropriate signatures.

  70. How to use BeginInvoke C#
  71. How to use BeginInvoke C#

  72. Call a Method Asynchronously using Delegate BeginInvoke and EndInvoke Pattern
  73. In this article, we will explore multiple ways to call a method asynchronously using Delegates. You can call methods asynchronously in four different ways using the BeginInvoke() and EndInvoke() methods of the Delegate class. The four different ways are using the EndInvoke pattern, WaitHandle, Polling pattern and using a Callback Pattern. In this article, we will see the Delegate EndInvoke Pattern. In the subsequent articles, we will explore the Polling Pattern and Callback pattern.

  74. Calling Asynchronously Method Using BeginInvoke Method in C#
  75. Sometimes we need to call a method asynchronously and don't want to wait until it completes execution.

  76. C# : ASYNCHRONOUS PROGRAMMING USING BEGININVOKE AND ENDINVOKE METHODS
  77. There are numerous instances in software development where you would find yourself in a need to build responsive apps, an important part of which is the asynchronous way in which you would need to do certain operations like I/O, intensive DB reads or probably making a call to a third party web service hosted somewhere on the cloud.

  78. Use BeginInvoke and callbacks to perform tasks asynchronously in C#
  79. The example Use BeginInvoke and EndInvoke to perform tasks asynchronously in C# explains one way to call a method asynchronously so it can run on a separate core or CPU. In that example, the program calls BeginInvoke several times to start several threads. It then calls EndInvoke to wait for the threads to complete and waits until they are all finished. While it waits, the main UI thread is blocked waiting for the EndInvoke calls to return.

  80. Threading in .NET and WinForms
  81. Guide to handle threads in .NET and WinForms.

    This article is to guide you through creating and handling threads in .NET. It has two sections: in the first section, we will see about threading basics and how to create threads in .NET using C#. In the second section, we will see how to handle threads in WinForms.

  82. Call a Method Asynchronously using Delegate BeginInvoke and EndInvoke Pattern
  83. Abstract: In this article, we will explore multiple ways to call a method asynchronously using Delegates. You can call methods asynchronously in four different ways using the BeginInvoke() and EndInvoke() methods of the Delegate class

  84. .NET Framework Delegates: Understanding Asynchronous Delegates
  85. An article to help clarify delegates and how to use them asynchronously.

  86. What's up with BeginInvoke?
  87. Why and when to use Control.BeginInvoke()?

  88. Asynchronous Method Invocation
  89. How to use .NET to call methods in a non-blocking mode.

    In this article, I am going to explain asynchronous method calls and how to use them. After playing with delegates, threads, and asynchronous invocation for so long, it would be a sin not to share some of my wisdom and knowledge on the subject, so hopefully, you won’t be looking at an MSDN article at 1 AM wondering why you decided to go into computers. I will try to use baby steps and lots of examples… Overall, I will cover how to call methods asynchronously, how to pass parameters to such methods, and how to find out when a method completes execution. Finally, I will show the Command Pattern in use for simplifying some of the code. The big advantage with .NET asynchronous method invocation is that you can take any method you have in your project, and you can call it asynchronously without touching the code of your method. Although most of the magic is within the .NET framework, it is important to see what is going on in the back, and that’s what we are going to study here.

  90. Changing a WinForms Control on the 'UI' Thread from another Thread
  91. this.BeginInvoke()..

  92. Proper Threading in Winforms .NET
  93. Illustrates a simple example of using the Invoke capabilities of Winforms

  94. Getting Around InvokeRequired Without Copy and Paste
  95. Instead of copying and pasting the same if(InvokeRequired) logic in every multithreaded function, use attributes to make code cleaner, its centralize logic and make it self documenting.

  96. Threading and UI
  97. A simple asynchronous threading example for keeping the UI code relatively free from worker thread delegate proxy declarations.

  98. Presents an implementation of a Spiral Tic-Tac-Toe AI using a vanilla Negamax search algorithm and WPF DrawingVisuals
  99. his article presents a WPF implementation of Negamax, an AI game search algorithm, in the context of a Spiral Tic-Tac-Toe game. The implementation of Negamax is vanilla and requires little explanation, but it does serve well as a fun way to get familiar with WPF. Rather than discussing the details of Negamax, this article discusses what needs to be done to reach the goal, which involves going over WPF threading as well as the use of DrawingVisuals. Additionally, there remain clear areas of improvement you may choose to explore. In order to reach a greater search depth, you can improve Negamax with a search tree pruning technique such as alpha-beta pruning. Alternatively, you can adapt the algorithm to a 3D tic-tac-toe game, which can serve as a good motivation for getting familiar with WPF 3D graphics.

  100. Use BeginInvoke and callbacks to perform tasks asynchronously in C#
  101. Use BeginInvoke and callbacks to perform tasks asynchronously in C#

  102. What exactly does Delegate.EndInvoke do? Is it necessary to call? [duplicate]
  103. Working on a multi-threaded application at the moment and when raising an event instead of doing the normal handler.Invoke(); I am experimenting with handler.BeginInvoke();. Both work fine. However, for BeginInvoke I am using null for the last two arguments because there needs not be a callback and since there is no callback, there is definitely no need for data to be passed to a non-existent callback.

  104. Why does asynchronous delegate method require calling EndInvoke?
  105. Why does the delegate need to call the EndInvoke before the method fires? If i need to call the EndInvoke (which blocks the thread) then its not really an asynchronous call is it?

    very good resource on Threading

  106. Threading in C# - Joseph Albahari
  107. In this section, we cover the multithreading APIs new to Framework 4.0 for leveraging multicore processors:

  108. PART 1: GETTING STARTED
  109. C# supports parallel execution of code through multithreading. A thread is an independent execution path, able to run simultaneously with other threads.

  110. How to use BeginInvoke C#
  111. Could you tell me how can I use begininvoke exactly? What is Action type? Why there is blank brackets ()? And what does this mean =>?

  112. Six ways to initiate tasks on another thread in .NET
  113. Over the years, Microsoft have provided us with multiple different ways to kick off tasks on a background thread in .NET. It can be rather bewildering to decide which one you ought to use. So here’s my very quick guide to the choices available. We’ll start with the ones that have been around the longest, and move on to the newer options.

  114. ThreadStart Delegate:: Microsoft
  115. Represents the method that executes on a Thread.

  116. Creating threads and passing data at start time :: Microsoft
  117. When an operating-system process is created, the operating system injects a thread to execute code in that process, including any original application domain. From that point on, application domains can be created and destroyed without any operating system threads necessarily being created or destroyed. If the code being executed is managed code, then a Thread object for the thread executing in the current application domain can be obtained by retrieving the static CurrentThread property of type Thread. This topic describes thread creation and discusses alternatives for passing data to the thread procedure.

    Note Visual Basic and C# users can omit the ThreadStart or ParameterizedThreadStart delegate constructor when creating a thread. In Visual Basic, use the AddressOf operator when passing your method to the Thread constructor; for example, Dim t As New Thread(AddressOf ThreadProc). In C#, simply specify the name of the thread procedure. The compiler selects the correct delegate constructor.

  118. Thread vs Threadstart
  119. In C#, practically, I haven't observed any difference between the following:

  120. Constructors of Thread class in C#
  121. In this article, I am going to discuss the Constructors of Thread class in C# with some examples. Please read our previous article before proceeding to this article where we discussed the basics of Multithreading in C# with examples. As part of this article, we are going to discuss the following pointers in detail with examples.

    Very Good Summary

  122. iraSenthil/gist:930328
  123. Different ways to create and run thread

  124. Monitor And Lock In C#
  125. When working with a multithreading application it is very important for developers to handle multiple threads for a critical section of code.

    Monitor and lock is the way to provide thread safety in a multithreaded application in C#. Both provide a mechanism to ensure that only one thread is executing code at the same time to avoid any functional breaking of code.

    The Monitor class object uses the Monitor.Enter, Monitor.TryEnter, and Monitor.Exit methods. Once you have a lock on a code region, you can use the Monitor.Wait, Monitor.Pulse, and Monitor.PulseAll methods.

    It is associated with an object on demand.

    It is unbound, which means it can be called directly from any context.

    The Monitor class has the following methods for the synchronize access to a region of code by taking and releasing a lock,

    1. Monitor.Enter
    2. Monitor.TryEnter
    3. Monitor.Exit.

    Monitor locks objects (that is, reference types), not value types. While you can pass a value type to Enter and Exit, it is boxed separately for each call.

    Wait releases the lock if it is held and waits to be notified. When Wait is notified, it returns and obtains the lock again. Both a Pulse and PulseAll signal for the next thread in the wait queue to proceed.

  126. Monitor.Pulse(Object) Method
  127. Notifies a thread in the waiting queue of a change in the locked object's state.

    Remarks Only the current owner of the lock can signal a waiting object using Pulse. The thread that currently owns the lock on the specified object invokes this method to signal the next thread in line for the lock. Upon receiving the pulse, the waiting thread is moved to the ready queue. When the thread that invoked Pulse releases the lock, the next thread in the ready queue (which is not necessarily the thread that was pulsed) acquires the lock.