Jeffrey Richter's Blog

October 6, 2023

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

 •  0 comments  •  flag
Share on Twitter
Published on October 06, 2023 12:15

September 27, 2023

Atmosera and Wintellect are now one!

Atmosera and Wintellect: Unifying the applications, infrastructure and Azure services spectrum.

Azure is powerful and transformative. Azure is the nexus between software, infrastructure, and the cloud. Now, Atmosera and Wintellect have come together to deliver Azure services through a unified lens across the complete spectrum of applications, cloud, and managed services. 

Combining Wintellect’s industry leading practices around DevOps, automation, Data & AI, and cloud-native application development with Atmosera’s premier managed Azure services offerings has created a one-stop shop for Azure system integration, application design and development, managed Azure, and Azure InfoSec & Compliance.  Add in Wintellect’s global reputation as top trainers on the Microsoft platform and we are defining the category for application and Azure infrastructure expertise and service delivery. 

Transformative, full spectrum Azure solutions delivered via one platform.

Azure Professional Services 

Azure Apps & Infrastructure (migrate environments, apps, and data to Azure) Azure DevOps (deliver better software, faster and at lower cost) Data & AI (AI, Cognitive Services, Big Data, Bots, Power BI, and IoT Solutions) App Development and App Modernization (Modernize your applications and data) 

Azure Management 

Azure Support & Management (24x7x365 management of mission critical Azure environments) Azure Optimization (alignment of best practice, governance, performance, availability, functionality, security, and expense) Azure Security & Compliance (managed Azure security, data protection, and compliance) 

Software Developer Training 

For over 15 years, we have been Microsoft’s #1 software development training partner worldwide.  We offer private virtual developer training and public, virtual classes. Our instructors and content are the best of the best.  

Together we are:An Azure Expert MSP, the highest Azure accreditation a partner can achieve. There are only 60 Azure Expert MSPs in the world. Microsoft Advanced Specialists in Windows Server and SQL Server Azure Migration and Modernization of Web Applications in Azure.A talented staff including a Microsoft Regional Director, multiple Microsoft MVPs and ALM/DevOps Rangers. A Top 10 Managed Global Learning Partner A Microsoft US Partner of the Year – Intelligent Cloud: DevOps for 2019. 
 •  0 comments  •  flag
Share on Twitter
Published on September 27, 2023 23:30

A progesterone test kit can answer that. Work of Chula researchers

Is the pig pregnant yet? Are gilts ready for breeding? This is an important question that pig farmers want answered. In order to plan farm management for maximum efficiency.

In the past, accurate answers to these questions Farmers must have a lot of flying hours to observe the pregnancy of pigs. which for new generations of farmers may not be enough. In addition, the use of personal expertise, which is not in large numbers In surveying individual pigs to prove pregnancy For large farms, this is a time-consuming matter.

“Observing the pregnancy of pigs is difficult. And the main problem is that some female pigs do not show symptoms. This creates a chance of misdiagnosing the pregnancy. It is necessary to use science to help from the work of the research team of Assoc. Prof. Dr. Kittinan Komonphis together with the research team of Prof. Dr. Phadet Thammarak, showing the preliminary results of using test strips. prepared at the laboratory level in helping to solve the problem,” Professor Dr. Sirirat Renpipat, Director of the Diagnostic Test Development Center according to international standards Chulalongkorn University Therefore, this concept is used as a starting point for development. Innovative test strip for detecting progesterone in the blood of gilts. (Progesterone Test Kit)

“Pig is a popular meat consumed. It is one of the important economic animals of the country. Create income for farmers Effective farm management is therefore important for the economy and food production for the people. Checking pigs’ readiness for pregnancy Or pregnancy of pigs is therefore an important step in the management of the pig raising business and affects the planning of future pig trading management.” Prof. Dr. Sirirat Discusses the importance of innovation in testing for pregnancy in pigs.   

 •  0 comments  •  flag
Share on Twitter
Published on September 27, 2023 23:25

October 19, 2012

What's new in CLR via C#, 4th Edition as compared to the 3rd Edition

The 4th edition of my CLR via C# book is coming out next month and you can order it here. The new edition is updated for Visual Studio 2012, .NET 4.5, and C# 5; there is also some coverage of Windows 8. As the book focuses on the CLR & C#, the majority of the book is the same as in the previous edition since little has changed from the developer's perspective. As always, I do review each and every chapter, I apply any reported errata improvements, fix any bugs, typos, or improve wording if a reader reported that something was confusing. I also update version numbers, screen shots, and any current thinking that differs from thinking in the past.

However, I have also made some significant enhancements to the 4th edition. I have rewritten the Garbage Collection chapter so the material is updated and presented in more organized fashion. Second, the chapter on Reflection has been rewritten because Microsoft has redesigned the Reflection APIs and the new API is the one that will survive into the future. The old Reflection API still exists for backward compatibility but it will eventually fade away (I removed all content related to the old API). The new Reflection API MUST be used when building Windows Store Apps. The new Reflection APIs have affected other chapters too (such as the delegates chapter where I talk about how to dynamically create delegate instances at runtime).

Speaking of Windows Store Apps, I have updated many of the chapters with considerations when building Windows Store Apps. And, I have added a brand new chapter entitled "Interoperating with WinRT Components" that describes how to consume WinRT components from C#. The chapter also shows how to produce C# WinRT components which can be consumed from other languages (such as JavaScript or native C++).

The only language feature new to C# 5.0 is the support for a new and simplified asynchronous programming model. This model is very similar to the model I produced years ago via my AsyncEnumerator class which has been freely available as part of my Power Threading library. To address C#'s asynchronous programming model, I have completely rewritten the "I/O Bound Asynchronous Operations" chapter. OK, C# has introduced another tiny language feature via Callee custom attributes and I also show how to use them in the same chapter.

When the book goes to the printer, I will post the source code on the Wintellect website.

[image error]
 •  0 comments  •  flag
Share on Twitter
Published on October 19, 2012 13:34

October 17, 2012

Free Access to My Windows Store Apps Video Series

Jeff Prosise and I have been diligently creating our Mastering Windows Store Apps course throughout 2012. With the release of Windows 8 later this month we want to share some of the wonderful content that we've been working on with all of you!


 

I created a 9-part Windows Store Apps video series that is available to you for free. Each video is 10-20 minutes in length and touches on key aspects of Windows Store development. I hope you find the videos informative and that you'll share your comments and reactions with me. Simply post any thoughts or questions you might have under each video and I would love to engage with you.


 

We will be releasing segments through December. Check-out our upcoming release calendar and get up to speed quickly and efficiently and prepare to blaze the new trails in the fast and evolving world of Windows development.


 

Currently available course segments include:


 






 •  0 comments  •  flag
Share on Twitter
Published on October 17, 2012 14:01

April 8, 2012

Asynchronous Batch Logging without Blocking Threads

Recently, I had a student of my Threading class present me with a problem which many people have. He wanted his server application to batch a set of log entries into memory and to flush the batched entries out persistent storage periodically or after some number of entries were captured in the batch. This is an extremely difficult problem because there are many race conditions to consider. At any given time, any or all of the following could be happening simultaneously:

Multiple threads could add entries to the batch
The batch could hit the desired threshold forcing it to be flushed to the log
The timer could fire forcing whatever entries are in the batch to be flushed to the log. If the timer fires and there no batched entries, then no flush should occur and we just reset the timer.
While a batch is being flushed, new log entries could be added to a new batch

I thought this was such a common and interesting problem, that I decided to try my hand at it to see what I could come up with. When architecting scalable software, you always want to strive for solutions that don't block threads since they're such expensive resources. And so, I set out on a mission to solve all these race conditions without blocking any threads. This means that most thread synchronization locks are out of the question since they all have the potential for blocking threads. However, a SpinLock can be used since it doesn't block threads. However, a SpinLock should only be used around code that is guaranteed to execute for a very short period of time so that threads don't waste too much CPU time spinning. Below is my C# solution to this problem:

using System;
using System.Threading;
using Batch = System.Collections.Generic.List<System.String>;
 
public sealed class Log {
   private static readonly TimeSpan Infinite = TimeSpan.FromMilliseconds(Timeout.Infinite);
   private readonly SpinLock m_lock = new SpinLock(false);
   private readonly TimeSpan m_maxInterval;
   private readonly Int32 m_maxCount;
   private Batch m_batch = null;
   private Timer m_timer = null;

   public Log(Int32 maxCount, TimeSpan maxInterval) {
      m_maxCount = maxCount;
      m_maxInterval = maxInterval;
      CreateNewBatch();
   }

   // Returns reference to old batch so it can be flushed to the log
   private Batch CreateNewBatch() {
      // NOTE: This method MUST be called under the SpinLock unless called by the ctor
      var oldbatch = m_batch;
      m_batch = new Batch();
      if (m_timer != null) m_timer.Dispose();
      m_timer = new Timer(TimeExpired, m_batch, m_maxInterval, Infinite);
      return oldbatch;
   }

   private void TimeExpired(Object timersBatch) {
      Console.Write("Timeout: ");
      Boolean taken = false;
      m_lock.Enter(ref taken);
      Batch oldBatch = null;
      if (timersBatch != m_batch) {
         // This timer is not for the current batch; do nothing
         // Solves race condition where time fires AS batch is changing
         Console.WriteLine("Not for current batch");
      } else {
         if (m_batch.Count == 0) {
            // No items in the batch, reset timer & use the same batch
            m_timer.Change(m_maxInterval, Infinite);
            Console.WriteLine("No items, resetting interval");
         } else {
            // Items in the batch, swap to a new batch
            oldBatch = CreateNewBatch();
            Console.WriteLine("Forcing flush, creating new batch");
         }
      }
      m_lock.Exit();
      // If there was an old batch, transfer it
      TransferBatch(oldBatch);
   }

   public void Add(String msg) {
      Boolean taken = false;
      m_lock.Enter(ref taken);
      m_batch.Add(msg);
      Batch oldBatch = null;
      Console.WriteLine("Adding msg: Current count={0}", m_batch.Count);
      if (m_batch.Count == m_maxCount) oldBatch = CreateNewBatch();
      m_lock.Exit();
      // If batch swapped, transfer it
      TransferBatch(oldBatch);
   }

   // TransferBatch is static to make it clear that this method is
   // NOT attached to the object in any way; this is an independent operation
   // that does not rely on any object state or a lock
   private static void TransferBatch(Batch batch) {
      // NOTE: this should be called while NOT under a lock
      if (batch == null) return; // No batch to transfer, return
      
      // Start transfer of batch (I would do this asynchronously)...
      Console.WriteLine("Transferring {0} messages.", batch.Count);
      // Call a BeginXxx or XxxAsync method here to transfer the batch to the persistent store...
   }
}

class Program {
   static void Main() {
      // Some simple test code:
      var log = new Log(2, TimeSpan.FromSeconds(30));
      Console.ReadLine();
      for (Int32 msg = 0; msg < 500; msg++) {
         log.Add("Msg " + msg);
         Console.ReadLine();
      }
   }
}

In the code above, there is a potential problem depending on what you might use for your persistent storage: The TransferBatch method initiates the transfer by calling your desired asynchronous I/O operation (BeginXxx or XxxAsync method). But, TrasnferBatch does not wait for the transfer to complete. This means that another batch could fill and also call TransferBatch introducing yet another race condition where the 2nd batch gets written to persistent storage before the 1st batch. Now, in my student's case, the log entries were being written to a Windows Azure Storage Table and the partition key contains the time the messages were written to the batch which means that the Windows Azure Table will keep the messages in chronological order even if this race condition occurs. So, the code above works fine in this scenario.

However, if you are not using a storage system that automatically maintains message order, then you will have to modify the TransferBatch method above. At first, you might think you could call TransferBatch while under the SpinLock to maintain order. But, this is not guaranteed to work as the I/O operation is issued asynchronously which means that multiple I/O operations could be sent to the Windows device driver and a device driver is allowed to execute I/O operations in any order it chooses; so FIFO is not guaranteed. You could solve the problem by issuing the transfer synchronously while holding the SpinLock but then the SpinLock is not guaranteed to be held for a short period of time and this could cause excessive CPU spinning. Or, you could replace the SpinLock with a blocking lock but then your threads might block causes additional thread pool threads to be created reducing the scalability of your application.

What we need is a way to ensure that batch transfers execute one at a time in sequential order without blocking any threads. To solve this problem, I'd recommend the use of my ReaderWriterGate class which is in my Power Threading Library. I describe how the class works in this MSDN article. I'd create an instance of the ReaderWriterGate and then queue of methods to it which will write the batch to storage. The ReaderWriterGate maintains FIFO ordering and it doesn't block any threads as it uses a SpinLock internally too.

For me, this was an extremely challenging and fun problem to solve. I know a lot of people have a very similar problem and I hope that some of you will find my code above useful. I also think it is valuable to consider the code as a model for how many other problems can be solved without blocking threads thereby increasing your application's scalability.

 •  0 comments  •  flag
Share on Twitter
Published on April 08, 2012 18:09

January 24, 2012

We Are Hiring!

Business is good and we need YOU! Wintellect is currently seeking senior level technical development resources for both contract and permanent employment for our current client projects. If you want the challenge of keeping up with co-workers like Jeffrey Richter, Jeff Prosise, Keith Rome, or Jeremy Likness, have we got the opportunity of a lifetime. Please have lots of hands on development experience in the following technologies: C#, ASP.NET MVC, WPF, WCF, Silverlight and SQL Server. Experience with HTML5 and jQuery would be ideal also. If you can't tell, it's all cutting edge here at Wintellect so if you like doing the latest technology we'd love to talk with you. Please forward your resume and availability to Barbara Keihm, Director of Human Resources,bkeihm@wintellect.com.

 •  0 comments  •  flag
Share on Twitter
Published on January 24, 2012 05:59

December 4, 2011

September 20, 2011

Using the Windows Runtime from a Non-Metro Application

I know a lot of people believe that the new Windows Runtime APIs included in Windows 8 can only be accessed from Metro style applications. A big part of the reason why people believe this is because the version of Visual Studio that ships with the Windows 8 Developer Preview only supports creating Metro style applications. However, I set out this morning to use Windows Runtime APIs from a non-Metro application. Here's what I did.

First, in Notepad, I created the following C# source code in EnumDevices.cs:

using System;
using System.Threading.Tasks;
using Windows.Devices.Enumeration;
using Windows.Foundation;

class App {
static void Main() {
EnumDevices().Wait();
}

private static async Task EnumDevices() {
// To call DeviceInformation.FindAllAsync:
// Reference Windows.Devices.Enumeration.winmd when building
// Add the "using Windows.Devices.Enumeration;" directive (as shown above)
foreach (DeviceInformation di in await DeviceInformation.FindAllAsync()) {
Console.WriteLine(di.Name);
}
}
}

Second, I created a Build.bat file which I run from the Developer Command Prompt to build this code (This should be 1 line but I wrap it here for read ability):

csc EnumDevices.cs
/r:c:\Windows\System32\WinMetadata\Windows.Devices.Enumeration.winmd
/r:c:\Windows\System32\WinMetadata\Windows.Foundation.winmd
/r:System.Runtime.WindowsRuntime.dll
/r:System.Threading.Tasks.dll

Then, at the command prompt, I just run the EnumDevices.exe to see the output.


 

Let me also explain how the async stuff works:

The XxxAsync methods (like DeviceInformation.FindAllAsync above) is a Windows Runtime method (defined in Windows.Devices.Enumeration.winmd) that returns a DeviceInformationFindAllAsyncOperation object which implements the Windows Runtime's IAsyncOperation<TResult> interface where TResult is the Windows.Devices.Enumeration.DeviceInformationCollection type. This interface is defined in the Windows.Foundation.winmd file.

Using the await keyword causes the compiler to look for a GetAwaiter method on this interface. Since IAsyncOperation<TResult> does not define a GetAwaiter method, the compiler wants to look for an extension method. In the System.Runtime.WindowsRuntime.dll assembly is the static System.WindowsRuntimeSystemExtensions class. This class defines several GetAwaiter extensions methods and the compiler emits code that invokes the GetAwaiter extension method that takes an IAsyncOperation<TResult> and returns a System.Runtime.CompilerServices.TaskAwaiter<TResult> object (defined in the System.Threading.Tasks.dll which is why this assembly is referenced). Since TResult is the Windows.Devices.Enumeration.DeviceInformationCollection type, the await operator ultimately returns this type which is then used by the foreach loop. Inside the loop, I just display the Name property for each DeviceInformation object.


 

Because you cannot mark an entry point method (like Main) as being async, I moved the code that calls await into its own EnumDevices method, marked this method as async, and make it return a Task. Then Main invokes this method and calls Wait on the returned Task so that the application doesn't terminate until EnumDevices has run all the way through to completion.

 •  0 comments  •  flag
Share on Twitter
Published on September 20, 2011 10:23

June 8, 2011

Links to resources involving Jeffrey Richter

Recently, I have been involved with some videos related to threading and Windows Azure which I'd like to share with you:

I was the guest on an episode of AppFabric.TV released today! In this episode, I explain how asynchronous programming allows you to build scalable services. Watch the video here.
I recently did a Windows Azure roadshow in New York, Boston, Atlanta, and Washington, DC. The New York event was recorded and the introduction of it is available here.
Mads Torgersen of Microsoft's Visual Studio team did a Channel 9 video discussing the new Async CTP and he mentions my involvement with it. The cideo is available here. Mads mentions me around 10 minutes into the video.

I hope you enjoy these,
-- Jeffrey Richter (http://Wintellect.com/)

[image error]
 •  0 comments  •  flag
Share on Twitter
Published on June 08, 2011 14:34

Jeffrey Richter's Blog

Jeffrey Richter
Jeffrey Richter isn't a Goodreads Author (yet), but they do have a blog, so here are some recent posts imported from their feed.
Follow Jeffrey Richter's blog with rss.