Tuesday, May 31, 2011

Common Problem:

Popups are being blocked on browsers when the window is opened asynchronously. For example, needing to do some action on server before opening the window popup.

Since the window is not opened right after the user initiative, the window is being blocked.

The Solution:

  1. Opening the window with empty URL and give the window a name. window.open("", name, WindowProperties);
  2. Asynchronously do the round trip to the server and request for data calculation or some server actions.
  3. When returning to client, refreshing the opened window by calling window.open again with the relevant URL and the same window name. window.open(url, name, WindowProperties);
Posted by: Eran Nachum (c)
Post Date: 5/31/2011 4:05:00 PM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | | Trackback   #
 Thursday, May 26, 2011

.NET Framework 4 offers great multi threads tools and new API to handle the usage of it. One of them is the Parallel.Foreach method, which executes a foreach (For Each in Visual Basic) operation in which iterations may run in parallel. (You can see a good example of usage here on the MSDN website).

This method “makes life easy” in order to enable data parallelism over any System.Collections.IEnumerable or System.Collections.Generic.IEnumerable<T> data source.

On the other side, I am still working and maintaining some projects that had been coded using .NET 3 (C# 3.5) and in order to perform multi-threading processes there is a need to use some other complex API and manage it, such as: ThreadPool (in order to manage a pool of threads that can be used to post work items, process asynchronous I/O, wait on behalf of other threads, and process timers), WaitHandle which encapsulates operating system–specific objects that wait for exclusive access to shared resources, etc…

While reading some tech posts lately, I bumped into a great post that outline an implementation of this Parallel.Foreach method. You can find it in the link below and I think that it could make your life much more easier in order to perform and take advantage of multi-core processors and execute foreach loops in parallel.

Get it from here.

.NET 4 | C# | C# 3.5
Posted by: Eran Nachum (c)
Post Date: 5/26/2011 5:05:00 PM (Jerusalem Standard Time, UTC+02:00)
Disclaimer | | Trackback   #