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
R

RJGCarey

@RJGCarey
About
Posts
22
Topics
10
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Object synchronization method was called from an unsynchronized block of code.
    R RJGCarey

    Whoops! Solved the problem. My code changed the object that I had a lock on. Monitor looses track of which object has the lock. Exit tries to unlock the new bitmap which does not have a lock and then throws the error. The solution is to create a seperate locking object for monitor to lock, then change the bitmap, and unlock the object. Other procedures use the locking object also. Works. Thanks RCarey

    RCarey

    Visual Basic graphics debugging help question

  • Object synchronization method was called from an unsynchronized block of code.
    R RJGCarey

    The following code throws the error above. Module Base Public sub Clock Do If needsNewChart = True Draw = New clsDraw("clock", i_id, True) thdWorkerSub = New Thread(AddressOf Draw.DoIt) thdWorkerSub.Name = "Draw" thdWorkerSub.Start() thdWorkerSub.Join() Draw = Nothing End If Thread.Sleep(100) Loop End Sub End Module Public Class clsDraw Public Sub DoIt '491 lines of code that creates a new bitMap(theBmp) and draws a stock market "tick chart". 'There are two uses of Monitor.Enter > Monitor.Exit on other objects without difficulties in this code. Try lockedGraphics = Monitor.TryEnter(theFrm.bmpTicks, 50) If lockedGraphics = True Then theFrm.bmpTicks = theBmp End If If lockedGraphics = True Then Monitor.Exit(theFrm.bmpTicks) End If Thread.Sleep(10) theFrm.pbTicks.Invalidate() Catch ex As Exception Ers.Show(c_id & "theTks.Draw.DoIt-setdown2", ex) End Try End Sub End Class Monitor.Exit(theFrm.bmpTicks) throws the error. When you step through the code in the debugger, the lock is acquired and the bitmap is copied. I use Monitor to synchronize my threads in many programs that work together to track the stock market. I have not encountered this error before. Why is it occuring? Thanks. RCarey

    RCarey

    Visual Basic graphics debugging help question

  • vb2005 label click event problem
    R RJGCarey

    That was it! Because of "pretty indenting" the Handle.Label1.Click was out of site on the right side and was misssingin the box I was testing. Thanks RCarey

    RCarey

    Visual Basic visual-studio debugging help question

  • vb2005 label click event problem
    R RJGCarey

    I have a project created in VB5 and migrated to VB6, VBNet 2003, and VBNet 2005. I recently placed some labels on the form. When I clicked on the labels VS created the code to handle the click event. I placed my code in the event handler. When I ran the project in the debugger I clicked on the labels. Nothing happened! Labels are more complicated in 2005 compared to 2003. I checked their properties. Enabled is true. I don't see any others that would apply. What am I missing? Thanks RCarey

    RCarey

    Visual Basic visual-studio debugging help question

  • How to create a window handle.
    R RJGCarey

    My last post was just an abstract. The post prior to that has all the code. Starting the clock is the last thing in Form_Load. In my other applications the form is created in Sub Main. Here is the code. Public Sub Main() frmMain = New Form1 'new form frmMain.Show() 'show it Shw = New clsShow 'new class Shw.SetUp() 'set up the graphics cName = SystemInformation.ComputerName() 'get computer name handleEndWorking = Now.ToString("yyyyMMdd") 'set the handleendworking mySql = New clsMySql 'connect to the database hntB = New BarHunter.clsBase 'new hunting base class hntB.setUp = New BarHunter.clsSetUp 'new set up class hntB.setUp.DoIt() 'do the job hntB.setUp = Nothing 'dispose Application.Run() 'run End Sub Now I just discovered that when I run my Show Procedures from another thread it doesn't work. It modifies a bitmap linked to a picture box on the form and then invalidates that picturebox. Enable application framework sure creates a different critter. Thanks RCarey

    RCarey

    Visual Basic help tutorial question

  • How to create a window handle.
    R RJGCarey

    Here's my code. This code is in my 15+ other applications and it works all the time. Form1 Private Sub Form1_Load instDelFormText = New delFormText(AddressOf FormText) End Sub Public instDelFormText As delFormText Public Delegate Sub delFormText(ByVal inText As String) Private Sub FormText(ByVal inText As String) Try Me.Text = inText Catch ex As Exception Shw.Err("frmMain.WriteFormText " & ex.Message) End Try End Sub Module Clock Private Sub DoNewSecond() Try Form1.Invoke(Form1.instDelFormText, CObj("BarHunter 2005" & Space (100) & Now.ToString)) Catch ex As Exception Shw.Err("Clock.DoNewSecond " & ex.Message) End Try End Sub The failure occurs on Form1.Invoke etc Thanks RCarey

    RCarey

    Visual Basic help tutorial question

  • How to create a window handle.
    R RJGCarey

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dbgS As String bmpMain = New Bitmap(pbMain.Width, pbMain.Height) AddHandler pbMain.Paint, AddressOf pbMain_Paint bmpBars = New Bitmap(pbBars.Width, pbBars.Height) AddHandler pbBars.Paint, AddressOf pbBars_Paint instDelFormText = New delFormText(AddressOf FormText) Shw.SetUp() 'error handling is now available Try MySql.Open() Thread.Sleep(5000) dbgS = Me.IsHandleCreated Clock.Start() Catch ex As Exception Shw.Err("Form1_Load " & ex.Message) End Try End Sub Put in the sleep. It does sleep. put in dbgS. It Shows true. Same error. Thanks RCarey

    RCarey

    Visual Basic help tutorial question

  • How to call a procidure requiring arguments with new thread
    R RJGCarey

    Create a new instance of a class passing parameters. Create a new thread pointed at the sub in that class that does the work. Name and start the thread. If you want you can wait till the thread finishes(Join) and then dispose of the instance of the class. Here is a code snippet. SQL.B.setDay = New SQL.clsSetUpAnyDay(Now.Date) 'new class thdWorker = New Thread(AddressOf SQL.B.setDay.DoIt)'new thread thdWorker.Name = "setDay" 'name it thdWorker.Start() 'start thdWorker.Join 'wait till it finishes SQL.B.setDay = Nothing 'dispose Hope that helps. RCarey

    RCarey

    Visual Basic help tutorial question

  • How to create a window handle.
    R RJGCarey

    All of my applications have migrated to VB 2005. They all start from Sub Main in a module. Today I decided to create a new one and set "enable application framework" to true so that I can explore its new features. The program has been run many times as I add new components. There have been no apparent problems. I added code that creates a delegate to display the program's name and a date/time string as Form1's text. It is invoked once a second by a thread spauned by my "Clock" class that runs on a background thread. I encountered this error when it ran. Invoke or BeginInvoke cannot be called on a control until the window handle has been created. How does one create a handle for Form1? Why wasn't it created automatically when the application started? Thanks RCarey

    RCarey

    Visual Basic help tutorial question

  • monitor.wait/pulse CPUusage
    R RJGCarey

    I have a Visual Basic application that processes stock market data. It receives UDP packets from a satellite disc receiver and decodes the highly compressed data, creates and saves to file millions of 20 byte "ticks", builds one minute bar charting data, and then screens each tick for certain patterns. Since it is looking at 7800 stocks and processes about 85 million ticks a day, it is a very busy application. It runs on a home built computer with an ASUS motherboard, an AMD Athlon 64x2 Dual Core Processor 4400+, 2.00 GB RAM, and WINXP Pro. When I converted it from VB.6 to VB.Net 2003 I chose to use thread.suspend/resume code to synchronize the many threads. I was surprized and pleased to see that at the heaviest data load periods that Task Manager showed it using only 12% CPU capacity. When I converted it to VB.Net 2005 I discovered that thread.suspend/resume code had been depreciated. I chose to replace it with monitor.wait/pulse code. I was surprized and disappointed to see that Task Manager now shows it using 86% CPU capacity at peak periods. Is it possible that Task Manager runs differently in .Net Framework 1.1 and 2.0 and was showing me erroneous info in 1.1? Does monitor.wait/pulse code use alot more CPU cycles? Does anyone know about CPU overhead of the several other thread synchronizatiion methods? Thanks RCarey

    RCarey

    Visual Basic csharp asp-net dotnet question

  • Visual Basic 2005 deployment problem
    R RJGCarey

    Seems to work. Thanks for the help. RCarey

    RCarey

    Visual Basic question sysadmin debugging help

  • Visual Basic 2005 deployment problem
    R RJGCarey

    Sounds like I should deploy by copying the Release\***.exe to another computer. Is this true? What is the purpose of the bin\***.exe file? Thanks RCarey

    RCarey

    Visual Basic question sysadmin debugging help

  • Visual Basic 2005 deployment problem
    R RJGCarey

    For many years I have deployed my visual basic projects from my development computer to my production ones by copying the project's directory to the production computer. I then pin the project\bin\***.exe to the start menu. Works fine. Simple and quick. I can continue to debug on the production computer by running the project in DbgCLR.exe. I have now converted all to 2005. Confusion has arisen. I still have project\bin\****.exe; but now I've also got project\obj\debug\***.exe and project\obj\Release\***.exe. What the new ones for? Why does the debug .exe seem lag behind? Which is the proper one to run in production mode? I've Googled it. Not much to find. Thanks RCarey

    RCarey

    Visual Basic question sysadmin debugging help

  • Cross-thread operation not valid
    R RJGCarey

    I have migrated a VB.Net 2003 forms project to 2005 Express Edition. This went surprisingly well. One problem remains. The main form sets up a delegate system to update it's text property from a background thread. Public Class FormMain Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'other stuff frmTxt = New FormText(AddressOf WriteFormText) End Sub #Region "Delegates" Public frmTxt As FormText Public Delegate Sub FormText(ByVal inText As String) Private Sub WriteFormText(ByVal inText As String) Try Me.Text = inText Catch ex As Exception Shw.Err("frmMain.WriteFormText " & ex.Message) End Try End Sub #End Region End Class A class "Clock" runs on a background thread and updates the main form's text once a second to show the time. Public Class clsClock Private Sub MainLoop() '8/9/05 Do 'determine if it is a new second using Now.Second and set isNewSecond accordingly if isNewSecond = True Then frmMain.frmTxt.BeginInvoke("TheCore" & Space(100) & Now.ToString, Nothing, Nothing) End If 'do all kinds of things depending on the time Thread.Sleep(100) Loop End Sub End Class Running in .Net 1.1, this works fine, in .Net 2.0 it throws this error "Cross-thread operation not valid: Control 'FormMain' accessed from a thread other than it was created on." I have a system of delegates to update a progress bar from background threads and a system of delegates to write to a picture box from background threads. Both of these work correctly in 2005. Help and my books have not solved the problem. Several hours of Google has only found other folks with the same problem. Does anyone know how to fix it? Thanks RCarey

    RCarey

    Visual Basic help csharp tutorial question

  • enumerate objects
    R RJGCarey

    My program. I want to click a debug menu item and get a list of objects that exist at that time. Ditto for threads.

    RCarey

    Visual Basic csharp question

  • enumerate objects
    R RJGCarey

    Is there a VB.Net way to enumerate objects in a program running as a free standing exe?

    RCarey

    Visual Basic csharp question

  • Copy all files and folders
    R RJGCarey

    I found this on the web a few years ago. I do not remember where. Private Sub CopyDirectory(ByVal SourcePath As String, ByVal DestPath As String, _ Optional ByVal Overwrite As Boolean = False) Dim SourceDir As DirectoryInfo = New DirectoryInfo(SourcePath) Dim DestDir As DirectoryInfo = New DirectoryInfo(DestPath) ' the source directory must exist, otherwise throw an exception If SourceDir.Exists Then ' if destination SubDir's parent SubDir does not exist throw an exception If Not DestDir.Parent.Exists Then Throw New DirectoryNotFoundException _ ("Destination directory does not exist: " + DestDir.Parent.FullName) End If If Not DestDir.Exists Then DestDir.Create() End If ' copy all the files of the current directory Dim ChildFile As FileInfo For Each ChildFile In SourceDir.GetFiles() If Overwrite Then ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), True) Else ' if Overwrite = false, copy the file only if it does not exist ' this is done to avoid an IOException if a file already exists ' this way the other files can be copied anyway... If Not File.Exists(Path.Combine(DestDir.FullName, ChildFile.Name)) Then ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), _ False) End If End If Next ' copy all the sub-directories by recursively calling this same routine Dim SubDir As DirectoryInfo For Each SubDir In SourceDir.GetDirectories() CopyDirectory(SubDir.FullName, Path.Combine(DestDir.FullName, SubDir.Name), Overwrite) Next Else Throw New DirectoryNotFoundException("Source directory does not exist: " + SourceDir.FullName) End If End Sub The recursive call is a bit confusing but this has copied my list of directories every night for at least two years. Should solve your porbelm also. RCarey RCarey

    Visual Basic help question

  • Form created by thread not responding
    R RJGCarey

    That's where I am now. The arrival of a packet sets the text of a menu item on the main form to the stock's symbol and beeps. I have to click the menu item to create a new form. this works but when events are fast this is too slow. I tried changing the text of a label on the main form which throws an event. An event handles creates the form but it is still not responsive to the user. RCarey

    Visual Basic mobile design question

  • Form created by thread not responding
    R RJGCarey

    I have a multithreaded program that draws stock market charts on as many as eight instances of a form. When I create instances of this form by clicking a menu item, they come up and are responsive to the user and the other threads. If I create a new instance from a thread other than the UI the form comes up but is not responsive to the user or the other threads. How does one do this? RCarey

    Visual Basic mobile design question

  • Form created by thread inaccessible
    R RJGCarey

    I have created a new instance of a form from a thread that responds to incoming UDP packets from another computer. This form shows up in the screen but the user cannot use it’s command buttons. Other threads cannot manipulate it’s variables or cause a paint event on it’s picture box. How does one accomplish these things? Thanks. RCarey

    Visual Basic 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