Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
N

NeilPrice

@NeilPrice
About
Posts
6
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Streamwriter and thread safety
    N NeilPrice

    I wrapped a synclock around there for good measure but it turns out that was unrelated to this hanging issue I was experiencing. I think I had two lines of code outside of any kind of Try-Catch mechanism in the whole thread part of the service - it turns out apparently you have to set a variable before logging what it is :rolleyes: Just about sums up my week really, I can't believe I did that =/ On the bright side I'm a lot more confident in the logging part of the code now anyway ;) Thanks for your input!

    Visual Basic csharp tools help tutorial

  • Streamwriter and thread safety
    N NeilPrice

    I was thinking the log route myself, I'm not a big fan of doing it this way but it's mandated for me right now unfortunately. Sadly, the amount of logging that's actually thrown out there over the life of the code (services) would end up sucking up all the memory way before it dies naturally. Unfortunately when it does go wrong it doesn't crash *OR* close naturally, it's still running to all intents and purposes just hanging which is what was leading me to wonder if thread contention could be coming into play. Thanks for your response!

    Visual Basic csharp tools help tutorial

  • Streamwriter and thread safety
    N NeilPrice

    I'm a little concerned about thread safety and I'm not sure how to interpret the MSDN docs in this case. I'm making use of a VB.NET Module that has a public function for the code base I am working on to log events. This logging function can be called from anywhere at any time. The code skeleton looks like;

    Module Utility
    ...
    Public Sub LogSomething(ByVal logData as string)

    ... // do work here

    Dim srLog as StreamWriter = new StreamWriter() // which opens a common file

    ... // finish up work here

    End Sub
    ...
    End Module

    Is this thread safe? Could this turn into an issue? The code I'm looking at hangs occasionally for no apparent reason and I'm wondering if there's any possible way this could be influencing what's happening since every thread whatever it's doing is making use of this logging function. Thanks! Neil

    Visual Basic csharp tools help tutorial

  • Instant CPU Utilization Value
    N NeilPrice

    Thanks for the answer Thomas. I wanted to trudge through the WinAPI to find something but even with googling didn't really find a good place to start. I ended up coming up with a tiny service app that runs on the computer and tracks CPU Utilization using the counter sampling then responds on a tcp port to a request for the current value. Probably overkill but it beat not having a solution :)

    Visual Basic tutorial database performance question

  • Instant CPU Utilization Value
    N NeilPrice

    Does anyone know if there's a painless way to get an instantaneous reading for CPU Utilization? I realise I can use a PerformanceCounter to call .RawValue but I have no idea how to convert that to anything that means anything. I don't want to have to take 2 values (ie. using .NextValue or .NextSample on the performance counter) as I know how to do this (see the example code below)

        Dim myCounter As System.Diagnostics.PerformanceCounter = New \_
        System.Diagnostics.PerformanceCounter()
    
        myCounter.CategoryName = "Processor"
        myCounter.CounterName = "% Processor Time"
        myCounter.InstanceName = "\_Total"
    
        Console.WriteLine(myCounter.NextValue().ToString())
        System.Threading.Thread.Sleep(1000)
        Console.WriteLine(myCounter.NextValue().ToString())
    

    I realize that the CPU utilization value is a sampled value and *not* an instantaneous one but I'm thinking there must be a way to query whatever value Task Manager currently has - but I can't see a way of doing that? (If you're wondering, I have a time critical app that I'd like to record a timestamp with current CPU Utilization in a log - the value doesn't have to be perfect but having a value is better than not having one.) Thanks!

    Visual Basic tutorial database performance question

  • Firefox Download Day
    N NeilPrice

    That was disappointing... I got all excited thinking I could crash it following your post and it ran just fine...

    The Lounge com question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups