Alle Beiträge von Sascha Baumann

Sundays IT: Ever wondered, why chrome runs so many processes ?

Hi everyone,

did you ever ask yourself, why the hack is chrome running so many processes ?

Image of Windows Taskmanager

This image shows only 5 processes, but this can go up to an nearly insane amount.
According to some articles I read, chrome encapsulates every single page into its own process, to prevent crashing the browser when one page goes down.

Chrome provides a way, to get an overview of the processes it runs. To see it, go to you menu => more tools => Taskmanager

Image of Chrome Taskmanager Menu

Image of Chrome Taskmanager

And here you see the different processes Chrome is using. There is one for the browser itself, some additionals for certain features (In this case GPU) and one process for every page you have open at the moment.

Have a nice sunday
Sascha

Sundays IT: Windows Update on my Win7 machine is stuck at 0% again – 4 Steps solution

Hi everyone,

its annoying when Windows Updates just is not working and its download percentage is Stuck at 0%. I like to share my process to solve this issue – So I do the following:

  1. Opening a command prompt with elevated permissions by typing cmd in my searchbox, right-click and select “run as aministrator” or just type cmd into the box and hit CTRL+Shift+Enter.
  2. Stopping the update service by typing net stop wuauserv into the command prompt and hit enter.
  3. Deleting the contents of C:\Windows\SoftwareDistribution using the windows explorer.
  4. Starting the update service by typing net start wuauserv into the command prompt and hit enter.

After that, I need to scan for new updates again (May take a while, since the cached information is gone). Downloading them should now work as expected.

DISCLAIMER: Reproduce at your own risk and without warranties.

Have a nice sunday
Sascha

Sundays IT: Harddisc was going crazy

Hello everyone,

I have no idea how it happend, but suddenly the system harddisc on my good old Windows 7 machine went crazy. After some exploration with Resource Manager (PID: 4 – System was the bad guy) and browsing the internet I stumbled across an article about Prefetch and Superfetch.

serverfault.com – system-process-pid-4-constantly-accessing-the-hard-disk

Some time later, after checking out the configuration of these two values in my registry, I decided to limit the fetching to the startup time. Different settings for this entries can be found here:

https://en.wikipedia.org/wiki/Prefetcher
https://de.wikipedia.org/wiki/SuperFetch

And finally after rebooting, my harddisc goes quiet again. Still have no idea what the cause of that problem was still the values in the registry been the default values. Maybe some Windows Update lately, that expected me to suddenly have an SSD in my old machine 😉

Maybe someone finds this useful.

DISCLAIMER: Reproduce at your own risk and without warranties.

Cheers
Sascha

DotNetFiddle mit Unterstützung für F#, ASP.NET MVC und NuGet Packages.

Guten Abend,

leider konnte ich auf der Webseite DotNetFiddle.net keine Release-Notes finden.
Allerdings wurde irgendwann zwischen Januar und jetzt der Funktionsumfang dieses Tools für “.NET im Browser” nochmal deutlich aufgebohrt.
Man kann nun als Sprache F# zusätzlich zu den bisherigen C# und VB.NET nutzen, NuGet Packages,wie man aus Visual Studio Projekten kennt, einbinden und auch Fiddles für ASP.NET MVC erstellen.

dotnetfiddle_newfeatures_20140317

Bild: Screenshots von DotNetFiddle.net

C#: Lookup vs. Dictionary

Lookup (Namespace: System.Linq)

Lookup<Tkey, Tvalue> 
: ILookup<Tkey, Tvalue> 
: IEnumerable<IGroupin<<Tkey, Tvalue>>

A Lookup is a collection which implements the ILookup Interface. It was introduces with LINQ and can be used instead of Dictionary.

A key don’t has to be unique, so you can have multiple entries with the same key. Also the Lookup is immutable, that means you can not add values on the fly, like you could with a List or Dictionary. You can however determine its count (.Count) and you can access the items with [value].

When you look up a key that does not exist in the Lookup, you don’t get a KeyNotFound-Exception but an empty sequence instead.

You cannot directly instantiate a Lookup, it is a result of a LINQ-Selection, which needs a Func for Key-Selection and a Func for Value selection.

Here is an example:

var myList = new List<KeyValuePair<int, string>>
            {
                new KeyValuePair<int, string>(30, "Sam"),
                new KeyValuePair<int, string>(10, "Hans"),
                new KeyValuePair<int, string>(10, "Fred"),
                new KeyValuePair<int, string>(20, "Sepp"),
                new KeyValuePair<int, string>(10, "Ron")
            };

var myLookup = (Lookup<int,string>) myList.ToLookup(
                                             (item)=>item.Key, 
                                             (item)=>item.Value
                                             );

var len = myLookup.Count;
var entry = myLookup[10];

Dictionary (Namespace: System.Collections.Generic)

Dictionary<Tkey, Tvalue> 
: IDictionary<Tkey, Tvalue>
: ICollection<KeyValuePair<Tkey, Tvalue>>, 
: IEnumerable<KeyValuePair<Tkey, Tvalue>>

A key has to be unique, so you can have only one multiple entry with the same key. The Dictionary is mutable, that means you can add values on the fly. Also you can use normal collection methods to determine its count (.Count) and to access the items with [value].

When you look up a key that does not exist you get a KeyNotFound-Exception.
You can directly instantiate a Dictionary.

Here is an example:

var myDictionary = new Dictionary<int, string>();
myDictionary.Add(10,"Hans");
myDictionary.Add(20, "Fred");

var len = myDictionary.Count;
var entry = myDictionary[10];

Blogpost Original Date: 16.02.2010, Updated: 13.12.2013

Pinnwand KW 47 / 2013 – Glimpse Developer Dashboard, Nicht unterstützte Features in Windows Phone, XAML Performance Video

  • Scott Hanselman stellt in seinem Artikel das “Developer Dashboard” Glimpse vor. Persönlich habe ich es noch nicht eingesetzt, ist aber auf jeden Fall eine Option für zukünftige ASP.NET oder MVC Projekte.

Pinnwand KW 46 / 2013 – Vorlagen für Felder in ASP.NET MVC, KnockoutJS, Neu in XAML in Windows 8.1

  • Eine gute Zusammenfassung zum Thema “Vorlagen für Felder” in ASP.NET MVC von Holger Schwichtenberg und Manfred Steyer findet sich bei Windows Developer.
  • Eine dreiteilige Artikelserie “Beginners Guide Knockout.JS” findet man bei Sitepoint

Dirty Hack: Sharepoint DelegateControl manipulieren

Hallo zusammen,

keine Lösung die ich euch wirklich empfehlen möchte, mehr eine Notlösung falls Ihr mal in die Verlegenkeit kommt ein Layout-Detail in einem DelegateControl ändern zu wollen, und nicht wirklich Einfluß auf den Rest habt bzw. keine unnötigen Konflikte riskieren wollt.
Nachfolgend ein Beispiel, das die Grafik eines Submit-Buttons innerhalb eines DelegateControls verändert.

var dg = this.ChangePasswordDelegateControl as Control;

if (dg != null && dg.Controls.Count > 0)
{
  var control = dg.Controls[0].FindControl("imgbtnChangePassword") as ImageButton;
  if (control != null) control.ImageUrl = "/images/special_submit_bt.gif";
}

Viel Spaß
Sascha

JavaScript ausführen wenn sich UpdatePanel aktualisieren

Hallo zusammen,

Möchte man auf Seiten mit mehreren UpdatePanels gezielt Javascript ausführen, wenn sich ein bestimmtes Panel aktualisiert, kann man das über den Javascript-PageLoaded Event der Hauptseite realisieren. Dieser Event liefert Informationen über die aktualisierten Panels mit. Im folgenden Beispielcode gehen wir nur von einem Panel aus, das Array aus get_panelsUpdated kann aber auch komplett ausgewertet werden.

<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);

                function pageLoaded(sender, args) {

                    var panels = args.get_panelsUpdated();
                    var panelID;

                    if (panels.length > 0) {
                        for (i = 0; i < panels.length; i++) {
                            panelID = panels[i];
                        }
                    }

                    var panel = panelID.id;
        
                    if (panel.indexOf("MyPanelId") > -1) {
                           // Do something
                    }
              }
</script>

Noch ein Tip: Verschiedene Zustände eines UpdatePanels (Zum Beispiel bei MultiViews) kann man auch einfach über die Prüfung von Layoutelementen erreichen. Für die ReadOnly Ansicht kann man zum beispiel ein HTML-Element mit der ID ReadOnlyView in die entsprechende View packen. Ist es vorhanden, ist das Panel in der ReadOnly Ansicht und man kann entsprechend JavaScript ausführen.

Viel Spaß beim ausprobieren
Sascha

Easy usage of INotifyPropertyChanged with Property-Attribute

Hello everyone,

today I want to share an implementation I’m using in my personal prototyping-Framework for Silverlight. This is important to mention, because I have tested it only for “works” but not including any productive parameters like memory-usage or processing-time.

The meaning of a prototyping-framework for me is to get thinks working as quick as possible, to show the outcome to my customer. There are some things I need very often, and so I’m using base-classes a lot.

Easy usage of INotifyPropertyChanged with Property-Attribute weiterlesen