473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Odd Threading Issue...

Hello all -

I am experiencing an extremely odd bug with an application I've created and I cannot figure out why it is doing this...

The application generates weekly reporting stats as Excel files by copying the previous week's file with a new name (ex: 04-06-2009.xls - Monday of the week the stats will be generated for), clears the data within the workbook and inserts the selected week's stats that are pulled from raw data extracts.

This portion of the form contains a date/time picker with the initial value of March 18, 2009, a label, a text box and a button to browse for files if a previous stats file needs to be rebuilt. The date/time picker obviously allows for the user to choose a date for the new file. On the DTP value changed event, it locates the previous week's file and inserts the file path into the label as it's text, generates the new file name and sets the textbox text to that file name.

Expand|Select|Wrap|Line Numbers
  1.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Try
  3.             Control.CheckForIllegalCrossThreadCalls = False
  4.  
  5.             ' Set the date for the dtpWeeklyExportDate date chooser
  6.             Me.dtpWeeklyExportDate.Value = Date.Today.ToShortDateString()
  7.         Catch ex As Exception
  8.             Me.ToolStripStatusLabel1.Text = ex.Message
  9.         End Try
  10.     End Sub
  11.  
  12. Private Sub ExecuteImportToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExecuteImportToolStripMenuItem1.Click
  13.     Progress.ShowDialog()
  14. End Sub
  15.  
  16. Private Sub Progress_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
  17.     Dim strSource As String = Form1.lblWeeklyExportFile.Text
  18.     Dim strDest As String = strSource.Substring(0, Form1.lblWeeklyExportFile.Text.LastIndexOf("\") + 1) & Form1.txtWeeklyNewFileName.Text
  19.     File.Copy(strSource, strDest, True)
  20. End Sub
  21.  
The problem is that as soon as the background worker is called, the strDest defaults to the first "Monday" value that was originally assigned to the textbox during the application initialization, which is pulled from the March 18th value assigned in design mode rather than the current text value...

Any help would be greatly appreciated!

-Tyler
Apr 10 '09 #1
2 1023
Update:

I altered the code so that the File.Copy() method is not being handled by the background worker but is handled by the Progress.Shown() method and it works as it is supposed to... So the problem is that the thread is somehow grabbing what the text box was first assigned... I have no idea why it is doing this but I'm sure it's a memory bug or something... Help please?
Apr 10 '09 #2
Well it's fixed for those who viewed and decided that they needed to know how... It must have been a memory issue or something but I still don't know why this happened...

As the progress dialogbox initiates, I assigned the current textbox value from the parent thread to a form specific first child thread's public variable during the Progress.Activated() subroutine, which maintains that value for the progress' child thread to reference to; since it's now operating within it's "own" thread and not two threads away, everything works like a charm... Why it referred back to an older value from the parent's parent thread (even though it was supposed to have been over written in the same block of memory is unknown to me), I don't know...

In conclusion, I believe it would be best if I picked up a book that specifically outlines multi-threading (NOT produced by Microsoft as this is where my debugging issues began and they didn't know why or how to fix it either even though I followed their "logical" examples to begin with). Outsourcing SUCKS!
Apr 15 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Zuel | last post by:
Sup everyone! I wrote this code for Tomcat appserver but I am told from an associate that it has threading issues. The basic idea is to store a read only data table for everyone to use. It...
19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
0
by: James R. Saker Jr. | last post by:
I've got a: "start server thread > Queue object, start server thread <> Queue object, start parsing client < Queue object" application that's got me puzzled. Probably an easy threads issue, but...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
13
by: John | last post by:
I've got some reasonably complex business logic in my C# code, in a class called by a ASP.NET page. This takes around 3-4 seconds to execute. It's not dependent on SQL calls or anything like that....
4
by: JimD | last post by:
Is this safe? Any pitfalls? I have done threading in regular C# apps, but haven't had a needs to do threading in ASP.Net, until now. The issue I have ran into is this: Our corporate portal...
2
by: WXS | last post by:
When I see things in .NET 2.0 like obsoletion of suspend/resume because of the public reason MS gives of they think people are using them inappropriately.. use mutex, monitor and other...
0
by: R K | last post by:
I am delevoping a Scheduler module whose functionality is to load the Scheduled Item Details every day (For this I have created a System.Threading.TimerCallBack with Timespan 1 day) in a stack. Once...
126
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.