WinForms - Writing To File In MultiThreaded App Fails

Jul 11, 2011

I have a multi threaded app that writes log to file. occasionally, saving fails using this code:
Friend Sub SaveToText(ByVal FileName As String, ByVal Text As String)
'// create a writer and open the file
Dim objLock As New Object
SyncLock objLock
Dim tw As TextWriter = Nothing
[Code] .....

The error message I get:
The process cannot access the file 'error.log' because it is being used by another process.

View 1 Replies


ADVERTISEMENT

Winforms - Writing To Console And Stdout?

Jul 25, 2010

I have a winform app that is writing to console and it seems to work well. I'm using this code:

AttachConsole(-1)
Console.Out.WriteLine("Hellow world")
FreeConsole()

The question is:If I run the app's exe file from command line, and try to redirect the output into a file. It doesn't work.For example:

C: > myapp.exe > c:output.txt

I still get the output to console screen (c:output.txt file is created but empty), but I want it to to be saved into c:output.txt.

View 2 Replies

Reading DLL.Config File Fails?

Oct 27, 2010

In out app we use dll that are loaded as addins. At startup we search the config files for these dlls in the application folder.The config files are named MyAddin.dll.config. On a win2003 R2 server running terminal services (in a domain with a SBS 2008) some of the users have problems reading the config files. I get an UnauthorizedAccessException when opening the config files like this:

Dim fs As New FileStream(strfile, FileMode.Open, FileAccess.Read)
reader = New System.Xml.XmlTextReader(fs)
fs.Close()

When I rename the files to MyAddin.config this works fine. Is the OS restricting the access to xxx.dll.config files?

View 2 Replies

No Tag For XML File Element - Method Call Fails

Oct 27, 2010

I have this method:
Private Sub SetIfNotNull(ByVal input As Object, ByRef destination As Object, ByVal ConversionType As ConversionType)
If input IsNot Nothing AndAlso input <> "" Then
Select Case ConversionType
Case DealerTrackConnection.ConversionType._String
destination = input
[Code] .....

And here is one call in which it fails:
SetIfNotNull(ApplicantElement.Element("suffix").Value, NewApplicant.Suffix, ConversionType._String)
If the element from the XML file is nothing (there is no tag), the method call fails. but I am checking for nothing.

View 2 Replies

Application - When Try To Run The Publisher, It Fails And Reports That It Is Missing An XML File

Feb 22, 2009

I have just written an application in visual studio 2005, and would like to publish it for use on another computer. When I try to run the publisher, it fails and reports that it is missing an XML file that is located in the bin folder. I have checked the bin folder and the file is there. I am not sure what I am doing wrong? Has anyone else seen this type of error before?

Also, I should point out that while I was creating this app, I would some times copy the project to my desk top, and then change the name of the project folder. For example: myProgramV0 would be come myProgramV1. Then I would copy this back into where I normally keep my VB projects. I do not know if this had an effect on the program or not.

View 1 Replies

File Chunking Fails When Served From IIS7 To Firefox

Oct 16, 2010

I have written a generic file serving handler in asp.net/vb.net..I recently moved to a windows 7 box and am now debugging under IIS7, and this is where the problems occure.Whenever I serve a file to either FireFox or Chrome (IE8 works fine) from IIS 7, the download will fail.

- In FireFox the error is "[some file name and path].part could not be saved, because the source file could not be read."

- In Chrome the error is "Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error."

- In IE8 it works fine

If I run the same code in IIS6, it works fine.If I run the same code in the Visual Studio virtual web server, it works fine (on windows 7 or XP).I am rather concerned about this as our production web server will soon be IIS7; which I'm starting to really love, and would hate to revert to IIS6 just because this won't work in IIS7.I've tried a number of different patterns.It seems to always fail on the Flush() line with the error "System. Web.HttpException = {"The remote host closed the connection. The error code is 0x8007 0040."}"One thing I have noticed, if I move the flush statment to the finally clause or remove it all together; firefox will attempt to read the entire file - it appears to be looping through the entire block of code just fine, until it hits the flush statement.If I remove the flush statment I still get an error and it still tries to read the entire file before asking me to save it.[code]

View 2 Replies

Windows 7 Task Scheduler Fails To Run Batch File

Jun 28, 2011

I have set up several tasks on a new installation of Windows 7 and they are working as expected.But when I attempted to run a batch file it fails. It works fine from the command line and I can run it from the scheduler on Windows XP manually (although not on the timer yet).What is about batch files that I need to know to make them run from the Task Scheduler?

View 3 Replies

.net - System.IO Will Copy Files But Fails To Update Destinations File Attributes?

May 25, 2010

I have a little vb.net script that will copy a file, set its attributes to Normal, update the file time, and then set back the attributes to match those of the source file.

If IO.File.Exists(Destination) Then IO.File.SetAttributes(Destination, IO.FileAttributes.Normal)
IO.File.Copy(Source, Destination, True)
IO.File.SetAttributes(Destination, IO.FileAttributes.Normal)

[code]....

I however I'm encountering a quite strange problem. On some configurations, IO.File.SetLastWriteTimeUtc triggers an UnauthorizedAccess error, although the IO.File.Copy instruction worked very well.

View 1 Replies

C# - Multithreaded Drawing In .NET?

Jul 24, 2010

(Edit: to clarify, my main goal is concurrency, but not necessarily for multi-core machines)

I'm fairly new to all concepts on concurrency, but I figured out I needed to have parallel drawing routines, for a number of reasons:

I wanted to draw different portions of a graphic separatedly (background refreshed less often than foreground, kept on a buffer). I wanted control about priority (More priority to UI responsiveness than drawing a complex graph). I wanted to have per-frame drawing calculations multithreaded. I wanted to offer cancelling for complex on-buffer drawing routines.

However, being such a beginner, my code soon looked like a mess and refactoring or bug-fixing became so awkward that I decided I need to play more with it before doing anything serious.

So, I'd like to know how to make clean, easy to mantain .NET multithreaded code that makes sense when I look at it after waking up the next day. The bigest issue I had was structuring the application so all parts talk to each other in a smart (as opposed to awkward and hacky) way.

I have a preference for sources that I can digest in my free time (e.g., not a 500+ pages treatise on concurrency) and for C#/VB.NET, up to the latest version (since I see there have been advances). Basically I want something straight to the point so I can get started by playing with the concepts on my toy projects.

View 2 Replies

Can A Shared Method Be Multithreaded

Feb 28, 2012

As the question states, can a shared method of an object be multithreaded? I don't quite having threading down in my skillset, otherwise I would test myself. On the other hand, I am involved in designing class that could be part of a multithreaded application in VB.Net.

View 3 Replies

Chat Application NOT MultiThreaded

Mar 16, 2012

I don't want it to be MultiThreaded. i read some tutorials and have a good idea. but unfortuantely all the tutorials on the web write code without explaining. so is anyone here has a good knowledge with Chat application ? I know it's about sockets and stuff but i just need an explaination with code ;)

View 5 Replies

Create A Multithreaded Application?

Aug 20, 2009

I am using Visual Basic 2008 Express Edition and I want to create a multithreaded application.

View 13 Replies

Debugging The Multithreaded Programs?

Oct 29, 2008

I have a background thread that waits for data to come in. When data arrives, it fires off a call to the GUI thread.All works just peachy, except if there's ever a run-time exception in the GUI thread. If that happens, the debugger always halts at the point in the worker thread that called the GUI thread. It never shows the proper line that the error occured on.How do I get the debugger to stop at the error in the GUI thread?

Here's the pertinent code from the worker thread:

Code:
Public NotInheritable Class UIThreadMarshal
Private Shared _MainForm As Form = Nothing
Public Shared WriteOnly Property MainForm() As Form

[code]....

View 4 Replies

Make An Application Multithreaded?

Oct 14, 2010

After trying to make an application multithreaded, almost towards the end of the processing of 10,000 records, I get a webexception - operation timeout.Now it seems to process around 8000 records just fine, for each record it is also doing some business logic and with it, performing a call to a webservice.

without threading, its fine - no problems. with threading, we hit the issue.so there are 10,000 records to go through. this is of course slow when done in sync mode (Single threading) but much faster when placing items in the threadpool and waiting until completion.

im not sure exactly why the problem happens. how should I debug this when multithreading? its just odd that for around 3/4 of records, the calls are doing very well, then on the last bit to go, it bombs out.

again - no issues when single threading.update: seems to be after around 1000 records that have been processed that it seems to happen.the application calls out to an internal webservice which then does the direct callout to the "outside world" webservice. The internal webservice does some caching but shouldnt have any effect really.

The outside service it is calling is httpBinding. ReceiveTimeout is set to 00:10:00 (10 minutes) and bypassProxyOnLocal="false"im still not quite understanding why it would timeout after 1000 records because it seems to process the others just fine and does come back (or so it seems) when its making a call to the service

View 2 Replies

Build A Multithreaded App - Catch The Returning Value?

Dec 26, 2010

I'm trying to build a multithreaded app but I couldnt find anything on google on how to catch the value that the lambda function returns.

ThreadPool.QueueUserWorkItem(New WaitCallback(Function() As Integer
Value += 1
Return Value
End Function))

View 9 Replies

.net - Isolating Read And Write In Multithreaded

Mar 8, 2010

In a multithreaded application. I have a bunch of function that loop through a collection to read the information. I also have a bunch of function that modifies that same collection.

I'm looking for a way to isolate all the read and the write together. I don't want a write to be done while a read is in progress. I was thinking of using SyncLock on the collection object but this will block multiple read trying to work in parallel.

View 1 Replies

Managing Exception In Multithreaded Application?

Mar 20, 2009

I started throwing exceptions on a multithreaded application, and got a mess.There is a good tutorial on managing exceptions in multithreaded applications?

View 4 Replies

Multithreaded Application And Crystal Reports

Nov 16, 2009

I have developed a multithread Windows Application that requires to print various Docss/rpt's off. The problem is I get a "Load Report Failed" error message when creating a new instance of my embedded crystal report.

View 3 Replies

Send Message To All Multithreaded Clients?

Aug 2, 2010

Given the code, ss there a way to propagate messages send from any of the multithreaded chat client to all the other chat client:

First the main will call startClient:
Public Sub startClient(ByVal inClientSocket As TcpClient, _
ByVal clineNo As String)

[code]......

View 1 Replies

Sql - Stored Procedure For Multithreaded App - Timeout Expired

Jul 5, 2011

I have an application using taskfactory that creates multiple tasks which insert records into the same table in a database. I have jobs that cleanup the table when it gets too large and have the execution time-out set to 0 in options in sql server management studio. I keep getting the following error on the tasks when trying to do an insert using a stored procedure and set an exception handling process to sleep and try again. This does not help as it seems it timeouts on almost every attempt.Not sure how to handle this and ensure the table handles all these inserts. Tried including connect timeout = 600 in one of the processes connectionstring but this did not help.Also set sqlquerytimeout value in registry to 90 but still not helping.

ERROR: timeout expired the timeout period elapsed prior to completion of the operation or the server is not responding...

could not see the details of the error since visual studio 2010 debug options had to be set that way, but I will set a responsestream and capture but I rebooted sql server and somehow everything is fine now...not sure why.

Errors have reoccurred.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection)

[code]....

View 1 Replies

VB 2005 - Sync Lock In Multithreaded Programs

May 16, 2010

I have been reading through lots of sample code and explainations regaurding the uses of Sync lock in multithreaded programs but still am a little fuzzy on this.

Am I correct in assuming that if I have two or more threads running the same procedure which has a sync lock on a shared resource that the first thread to call the lock will complete its update of the resource and any of the other threads to try and lock this object would just wait in line until it is released by the first object?

I am also a bit fuzzy on what is actually locked by the sync lock.

Lets say I have code that uses sync lock and the object specified is the current thread. Does that also lock the shared resources that are referenced within the sync lock block or would I need to use another method to do this?

What if my shared resourses were all in another class and I issue a sync lock on that class before I try to modify the resources would that be the proper way to go about it?

And last but not least is there any need to use sync lock when the shared resource is in effect read only [meaning the program will read the value but will not change it during runtime]

View 8 Replies

VS 2010 - Showing Forms On Multithreaded Application

Apr 17, 2011

I've finally gotten multi-threading working on my application, but now I'm having trouble showing forms when I need to. I currently have three threads in my program: one for updating a textbox, one for transferring files, and one for displaying forms. Here's a snippet of code from my program:

[code]...

I'm getting the error: Control 'frmXCopy' accessed from a thread other than the thread it was created on. I know what this means, but I can't find a way to make the ShowForm Sub run off of the main application thread.

View 9 Replies

File I/O And Registry :: Reading/Writing Objects To File?

Jul 5, 2009

So I need to write out an object to a text file as well as read in objects from text files.How do I accomplish this? This is the code i've used to read and write just simple lines of text. Is there a small modification to this or just a different function i use to read in an entire object?

Code:
Dim path As String
path = "Security.txt"

[code].....

View 4 Replies

File I/O And Registry :: Text File Reading And Writing?

Jul 17, 2010

I have just recently been using VB 2010 after using VB5. I have noticed a lot of changes. The problem I have is that I wish to open and save text files to and from arrays in the background. I've attached what I would do in VB5. I have searched around, but all the examples I find use a Textbox instead of an array. Can anyone show me how I can do this with VB 2010?

View 1 Replies

Save File Dialog And Writing In Text File?

Jun 9, 2011

I am creating a text file using a save file dialog and copying the path to the text box which file is used to write from vb.net. when i try to write i get an error "The process cannot access the file '....fileName.txt' because it is being used by other program".

The code is below

Public Sub writeInTextFile()
Try
Dim oWrite As New StreamWriter(TxtOutputPath.Text)

[Code].....

View 4 Replies

Writing Array Of File Names To Text File

Mar 11, 2010

I am attempting to gather a group of file names from a directory. I am able to do this. I tested the code by having the list populate into a listbox and all desired items were added to the list.

Here is my code:
Dim di As New IO.DirectoryInfo(strPath)
Dim dir1 As IO.FileInfo() = di.GetFiles("*.txt")
Dim dFiles As IO.FileInfo
ListBox.Items.Add(dFiles)

However, a listbox is not my desired output. I am attempting to write these file names to a text file for purposes of then parsing the information to a datatable to compare with another datatable. How to get my filenames written to a textfile.

View 2 Replies

CORRECTLY Implement A Multithreaded Progressbar During A LINQ Query?

Oct 31, 2011

I have a linq query which loads approx. 1000 lines into a variable, during that process I want to display a progressbar, not necessarily stating the percentage, can be marquee style, doesnt matter.

This progressbar is on a modal form to precent the user from interacting with the app for the time the query's running.

[Code]...

View 3 Replies

Implement Multithreaded Crawler - Add A Unique Url To Each Thread To Go Process

Feb 1, 2010

I would like to implement a mulithtreaded crawler using the single thread crawler code I have now. Basically I read the urls from a text file, take each one and crawl and parse it. I know how thread basics of creating a thread and assigning a process to it but not too sure how to implement in the following way:

I need at least 3 threads and need to assign a url to each thread from a list of urls, and then each needs to go and fetch it and parse it before adding contents to a database. [Code] Now the code maynot make sense but what I need to do is add a unique url to each thread to go process.

View 4 Replies

Writing File/Folder Sync Prog, Result Text Boxes Not Updating Untill After All File Action Is Done Even Though Update Code Comes Before Copy?

Apr 12, 2011

I am working on a program using VB.Net 2010 which will enable me to setup groups of files & folders for back up with syncing capabilities etc. I have a concept program which is based on some sample code I found out in one of the VB.Net forums. I have modified it from a command line based program to a form based program. At the moment I consider this code to be a "concept" program which once I have the various copy/sync routines developed and debugged will be integrated in to another program I wrote for
creating "Back Up" groups to automate the process. There are some 3rd party programs that do similar things that I want to do such as Microsofts Sync Toy, but none of them offer the grouping and exclusions options that I am going to program in to this backup/sync program.

So here is my problem, I have the included code taking two folders, a source and a destination, and copying everything from the source to the destination. It will skip over any unchanged files/folders and will delete anything found in the destination folder that is not found in the source folder and it will update all files in the destination folder that have a newer version in the source folder. In other words it will mirror image the source to the destination but will be smart enough not to copy unchanged items from the source to the destination thereby saving a lot of time. The sync part of the program is working fine, the displaying of the progress and results is not.

[Code]...

View 2 Replies

File I/O And Registry :: Writing An Array To A File?

Jul 6, 2010

I have a structure in memory which is working fine - now I need to write this entire structure to a file.The below code almost compiles, the problem is that "mstaRecordInfo" cannot be changed to a string, probably because of the Date field. I've just spent over an hour experimenting and searching the web but have gotten no closer to a solution

[Code]...

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved