Asynchronous Processing
I need to kick off a program from inside my VB application. However, when I use SHELL, it seems that the application freezes until the shelled app finishes.
Is this the case? If not, then it would appear that the shelled app is hogging the system resources. Can I downgrade the system hog some way?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Asynchronous Processing
Anybody have any good methods to kick of a task asynchronously in a VB Project without having to shell it out? In other words, I have a main project, and some ActiveX .dlls for that project. Within those .dll's I'd like a process to run asynchronously, and then just raise an event in the main .exe when it's complete. I know how to raise events, I'm just not sure how to kick it off Asynchronously.
I could use a timer to do it in a form in the .dll, but there are no forms there now, and I'd hate to add a form to the project for the sole purpose of using a timer. Also, I'm going to have an unknown number of these processes to kick off, so it wouldn't be the cleanest code to instantiate all those forms so I could use their timer controls. A single form with a timer control array won't work because I've found that if I have several timers enabled at the same time in an array, some of the elements will simply quit firing, even though they are enabled.
TIA for any input on this.
Asynchronous Processing...
Hi.
I have an activex exe that handles an intense SQL query for my client application. Is there a way to get around the "Component Request Pending" dialog? I.E., I don't want my application to have to wait for a response from other program, but have the other program do it's stuff, then send info back to app when processing is complete. I've read about using a timer function, but will that work since I'm not looping?
Thanks,
David
Asynchronous Processing
hey, I have 2 dlls: Data and UI.
by default when you call a function from UI to Data, the code in UI waits for that function to finish and then it goes on with the rest of the code in UI.
i would like to make Asynchronous call to Data and return right away, i would still want that process to finish but i dont care how long it takes, i would like to return instantly.
how can i accomplish that?
Asynchronous Processing...
I'm developing an Out-of Process COM Server, and I'm trying to get my asynchronous calls to work. Right now, I'm just testing various examples to get the feel for it..For Example:
ActiveX EXE (Code)
Code:
Public Event MsgMessage()
Public Sub AsncExample()
For X = 1 to 30000
DoEvents()
Next X
RaiseEvent MsgMessage
End Sub
COM Client (Standard EXE)
Code:
Dim WithEvents oAsnc As CExample
Private cmdClick_click()
Set oAsnc = New CExample
Call oAsnc.AsncExample
End Sub
Private oAsnc_MsgMessage() '// This may or not be the right definition. I just free-handed this
MsgBox "Event Fired!"
End Sub
Now, on my standard exe, I have a text box, and when I call the COM's method, I am unable to type in the textbox. What am I missing?? Thanks All'
Asynchronous Processing
Thanks in advance for the help.
I am trying to do something rather straightforward, yet running into problems.
Essentially, I would like to open a login form(frm_DatabaseLogin) and have it disappear after 20 seconds if no input is received, or no button is hit. I know this is done with asychronous processing (possibly ACTIVEX), but I can't seem to find the right manner to do so.
Thanks in advance. BTW, I am using VB 6.0.
Asynchronous Processing
Dear reader
I am calling a procedure from ActiveX exe which takes a lot of time.
And I want my exe to run this procedure asynchronous & call back after finishing.I am getting callback but it's not running asynchronously.
Asynchronous Processing Part II
This is an extention of a couple of posts where I have a long running stored procedure and I am trying to keep the application from appearing to freeze up on the user. I followed up on suggestions to look into asynchronous processing and it does what I want in that the user can minimize/maximize the application so it doesn't seem locked up.
This introduced another issue. When the application is running it takes up 99% of the CPU. This might be OK for individual work stations but some of our customers connect through Citrix which means they are basically sharing the same server and I can't allow a single instance of the application do that. Here is some test code I'm running:
CODEPrivate Sub TestIt()
Dim strSQL As String
Dim cmdChange As ADODB.Command
Dim dCounter As Double
Set cmdChange = New ADODB.Command
strSQL = "exec rptAON 0, 32813,'','08/01/2005','08/18/2005','08/01/1981','08/18/2005',0,0"
cmdChange.ActiveConnection = conSQL
cmdChange.CommandText = strSQL
cmdChange.CommandTimeout = 0
Set rs = cmdChange.Execute(, , adAsyncExecute)
DoEvents
Do Until cmdChange.State <> adStateExecuting
DoEvents
Loop
End Sub
Ways To Create Asynchronous Processing
I know for an ActiveX exe object, you can use a timer to fire a new process and raise an event after. Are there other ways to achieve the same. for instance, Can I call a Activex Object method and fire a asynchronous process directly from client? Thanks for your help
Asynchronous Processing - Possibly With Threads
Hi all,
I have a little problem with some Async processing.
I have an app that will recieve emails from an inbox, and populate a
database with some of the email details.
This app will also read this data from the database and populate a form(s)
with this info as need be.
The problem I have is that the reading of emails and population of the
database and form needs to work seperately from the application without
hindering the application at all.
i.e. the processing of the emails and data should not affect the front end
of the application.
My question, is there any tutorials anywhere on how to write Async classes
or events to handle this and how to call them and time them etc??? I have
started reading about this using MSDN but it is just too confusing. I need
something a little more straight forward please.
If anyone has a tutorial or maybe some code I could plagurise (this is not
commercial - it is for the canteen at work so emailed orders can be sent
rather than people queueing - bosses are getting mardy about time taken)
Cheers
Jim
Asynchronous Processing Part II *Closed By Poster*
This is an extention of a couple of posts where I have a long running stored procedure and I am trying to keep the application from appearing to freeze up on the user. I followed up on suggestions to look into asynchronous processing and it does what I want in that the user can minimize/maximize the application so it doesn't seem locked up.
This introduced another issue. When the application is running it takes up 99% of the CPU. This might be OK for individual work stations but some of our customers connect through Citrix which means they are basically sharing the same server and I can't allow a single instance of the application do that. Here is some test code I'm running:
VB Code:
Private Sub TestIt() Dim strSQL As String Dim cmdChange As ADODB.Command Dim dCounter As Double Set cmdChange = New ADODB.Command strSQL = "exec rptAON 0, 32813,'','08/01/2005','08/18/2005','08/01/1981','08/18/2005',0,0" cmdChange.ActiveConnection = conSQL cmdChange.CommandText = strSQL cmdChange.CommandTimeout = 0 Set rs = cmdChange.Execute(, , adAsyncExecute) DoEvents Do Until cmdChange.State <> adStateExecuting DoEvents LoopEnd Sub
Any thoughts on how I can let the stored procedure run, don't go into a loop or have a loop that doesn't eat up the CPU, and then pick back up when the stored procedure has completed?
Asynchronous
Hi
I would like to introduce my situation, I am Implementing an Appication that connect to a SQL Server 2000 and retreive data from the database and display it in a Data Report, so what I have notice that it takes time untill doing this cycle,
so how can I doing this function [the function: which is open the connection to the database and retreive the data and show the Data Report] without freez my computer till this function finished?
Thank you for your concern
Roger
Synchronous Or Asynchronous
Hi,
I've created an application that uses sockets, and does so through the Winsock2 library with a Heck of a lot of Declare Function statements.
I've been asked whether the application uses synchronous or asynchronous socket selects. Given that most of the socket code was produced with Ctrl-C and Ctrl-V, I really couldn't say. I'm not aware that I'm using any asynchronous functionality, but am I still using asynchronous protocols?
And yes - this is an absurd situation, but management (a) don't want me to seem ignorant by asking the guy what he means, and (b) hired a unix programmer with limited networking experience.
Any socket help / job-offers appreciated.
-BoB
Asynchronous Subroutine
Hi, I'm having a problem with subroutines being called multiple times because the sub takes too long to complete. I need a way to call the subroutine (including sending it some variables) and then continue on as if it's already completed. Is there any way to do this?
Asynchronous Operations - Help!
Currently I have an application that reads incoming data which is used for controlling as well as monitoring a machine. I am displaying the incoming data I am reading from the device as well as data written to it in a list box and at the same time logging each line of incoming/outgoing data to a log file. The machine is a two state device where either it's running a lengthy process where it constantly sends data back to my program (sometimes two to three lines of data per second and each line can contain up to 100 characters (bytes) of data), or it sits idle. In idle state, it rarely sends any data unless some malfunction occurs within the system. I allow only about 100 lines of data to be viewable in the listbox, and when it reaches this number I clear the listbox and start fresh again. Program seems to be working fine at the moment but I am concerned about its reliability as certain processes can take several days. Assuming the device send back 3 lines of data per second, I would have 259000 + lines of data in the log file per/day. This means I am opening and closing the log file as many times and worried about the overhead that will be placed on the controlling program. I do not want to leave the file open for the duration of this process fearing if the program crashes or quits for some reason I run the risk of corrupting the log file.
So I have been entertaining the idea of creating a second program to handle the file I/O portion. This second program will run asynchronously with my main program. Idea is to have an invisible form with a Richtextbox in it where my Main program will send each line of data it receives and add it on to the richtextbox of the second program. Then the second program takes the data from the richtextbox (say when it reaches a line count of 100) and puts it in to the logfile. Thatway log file is open and closed only once per 100 lines of data.
First of all is this a sound idea?
I would like to try this out but unsure how to get it done. I’ve been reading up on Sendmessage and Postmessage but not easily grasping how to implement it. I am leaning towards POSTMESSAGE because I do not want the Main program to be delayed by waiting for a response from the 2nd program. I just want the Main program to dump the data in to the Ritchtextbox of the 2nd program and instantly go about doing it’s own business w/o worrying about the 2nd program.
Can someone guide me in the right direction? Or am I way-off thinking breaking this in to two programs (sort of multitasking) to get this done is the right thing to do?
TIA!
Asynchronous Function && Sub
How to make a function or a sub-routine run asynchronously when being called?
I want to run those function parallel with other processes.. It's similar to Timer Control where it runs on it's own (asynchronous)!!
Thanks in advance
Asynchronous Notifications
I urgently need a sample code on the following:
1) Asynchronous Notification via Call-Back methods
2) Asynchronous Notification via Events
Thanx
Asynchronous Functions
Hi to all,
this is may be a hard question:
How I can make an Asynchronous Function ???
I meant, something like a CodeTimer ??
I hope make sense
Thanks !
Asynchronous Problem?
Using a data environment (MS Jet 4.0 DB Provider). Have set up commands for each of the 4 tables (not using SQL statements). In frmMain, have DataGrid control with source of deTransfers & member of Location (1 of the tables = command).
The control includes all rows (fields) of the Location table, as it should. Have written procedures to add, edit, & delete a row. Using code below, when user deletes a row, gets error . . . "Row handle referred to a deleted row or a row marked for deletion." HOWEVER, when I step through (F8), execution does not stop! Works fine. Row gets deleted from record set & DB! When I do not step through & execution halts & I press Debug, execution is on the line following .Delete.
What is going on? Thanks for any suggs.
John
<pre>
private Sub mnuDeleteLocation_Click()
on error GoTo HandleError
With deTransfers.rsLocation
.Delete 'Delete the current record
.MoveNext 'EXECUTION stops here (after .Delete) when NOT debugging - Move to the following record
If .EOF then 'If last record deleted
.MovePrevious
If .BOF then'If BOF and EOF true, no records remain
MsgBox "The recordset is empty.", vbInformation, "No records"
End If
else: .MoveFirst
End If
End With
Exit Sub
HandleError:
MsgBox "Unable to carry out requested action.", vbInformation, "Video Bonanza"
on error GoTo 0
End Sub
</pre>
CommitTrans Asynchronous?
Hello,
I am accesing an Access XP database with ADO2.8 under WinXP SP1 and VB6. I do basically this
Code:
recordset.Open table, connection, adOpenStatic, adLockOptimistic
' Call a function that does this:
connection.BeginTrans
recordset2.Open table, connection, adOpenStatic, adLockOptimistic
add some data to recordset2, call update for each item
connection.CommitTrans
'return from the function
recordset.Close
recordset.Open table, connection, adOpenStatic, adLockOptimistic
Both recordset and recordset2 use the same table, one in a join query, the second one directly. The problem is that after this procedure ends, (sometimes?) recordset.EditMode = adEditInProgress. Do you know why? When I tried to go step by step through the code, everything went fine. When I run this code without breakpoints, I got this problem. Why? The only explanantion I can think out is that CommitTrans runs asynchronously and I must give it some time to perform its action. But I don't know how to find out if some transaction is in progres, for connection.State = adStateOpen during the whole code.
Thanks
Asynchronous Action?
Hi all,
I have an application with will moving the record and display in the chart by click a button. Does anyone know how make sure the action is asynchronous?What i mean here is how to make sure the next action is going after the action before completely done.
Any tips are welcome.
regards
lswang
Asynchronous Call
Dear All
I have created an activex exe which has a public sub GenReport.
This sub creates a report in xls format from the data in sql server.
Xls file is just saved in a folder.
In the Project Properties, I have marked Thread Per Object.
In my Standard Project, following is the code
Option Explicit
Private clRep as clMyReport
Private Sub Command1_Click()
rst.MoveFirst
Do While Not rst.EOF
Pb1.Value=Pb1.Value + 1
Set clRep = New clMyRep
clRep.GenReport rst!rep_name
Set clRep = Nothing
rst.MoveNext
Loop
End Sub
I was expecting an asynchronous working. But to my surprise,
It completes the execution of one report, then proceeds further and loops.
Is it possible to call same class multiple times from a standard module?
and asynchronously offcource?
Please reply soon.
Thank you
Radhesham
Asynchronous Execution ...
Okay, lets say I have a form and on form load i am populating 3 combo boxes. I am calling method1, method2, method3 to populate combo1, combo2, combo3 respectively. thing is method2 does not fire until method1 has finished executing. same for method3, it won't fire until method1 and method2 has finished executing. is there a way to fire all 3 methods asynchronously so all methods execute parallely. I tried Createthread API and it actually worked. They all ran asynchronously. But after form load my combo boxes started bahaving weird for some reason ... ?? anybody else ???
Asynchronous Calling Of Exe
Hi all,
I got a vb program(Main.exe) which will keep on invoking exe(s) according to the task list stored in registry. After each exe finishing executing itself, Main.exe will have to write something back to registry. My question is how can the main.exe keep invoking exe(s) while keep writing to registry after each exe finish its execution? Any API needed?
Thanks.
Asynchronous Sounds...
I am using the following code:
Code:
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_ASYNC As Long = &H1
Public Sub Command1_Click()
PlaySound "SystemExclamation", 0&, SND_ASYNC
End Sub
Public Sub Command2_Click()
PlaySound "SystemExit", 0&, SND_ASYNC
End Sub
I can't get it to play the two sounds at the same time..
I click command2, then I quickly click command1, and it stops 2 automatically....
How can I get them both playing at the same time?
Thanks,
Asynchronous MAPI
I am trying to send an email from an application I have developed
using VB6.0. When the user clicks an email adress in the application I
use the MAPI to open a new email. My problem is, that the
user cannot switch back to the application before the mail has been
sent. The reason is, that a component request is pending. I have tried
to solve the problem by sending the mail from an activex component
(the coffee project from the samples), since it claims to be
asynchronus when it is called from another exe. And it is - though not
when the task it has to perform is sending an email. Then the
asynchronous activex-exe suddenly blocks the exe, which initiateted
it.
If anyone has a solution to sending mail asunchronously I'll be glad to be hearing from you.
Regards,
Ingemann
Asynchronous ActiveX Exe
Hi,
I have an application running smooth on COM+. There is a Client layer, business layer and data layer. This application is running on Oracle database. There are certain stored procedures which are executed from the application that take around 1-2 hours. So, when this process is running the client application is blocked and there is nothing else the user can do with the application but wait for the process to complete. Currently, we are calling the stored procedure from the data layer. To solve this, we thought of doing the following.
* Create an ActiveX Exe.
* Call the Active Exe from the data layer.
* Call the stored procedure in the ActiveX Exe.
By doing this we thought that the data layer would free up and the control returns back to the application. But rightnow, it is not happening this way. The system still is blocked. Is there anyway that we can solve this using ActiveX exe.
Please help...
Thanks,
Rajesh
Asynchronous XMLHTTP
Hi
I have 2 modules, 1st module is a .asp page which is providing me with the data and the 2nd is a Visual basic application which is reading the data sent by the .asp page.
code in the .asp page
<%
Response.Buffer = True
For i = 0 To ....
...
....
Response.Write("<name>" & value & "</name>")
Response.Flush()
Next
%>
This loop is a big one and is taking atleast 3 minutes to complete.
Visual Basic application
Private Sub Command1_Click()
Dim x As New MSXML2.XMLHTTP40
x.open "GET", Text1.Text, True
x.setRequestHeader "User-Agent", "mozilla/4.0 (compatible; MSIE 6.0)"
x.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
x.send
Do While True
DoEvents
If x.readyState = 4 Then
Exit Do
End If
Loop
Text2.Text = x.responseText
End Sub
I am getting the result when all the content is available to me, and that is after waiting 3 minutes.
My objective is to keep on getting the flushed data from the server and show it into a textbox while the loop is still running in the server application.
This is very common to the browsers, like even if the entire content are not available to the client, the browser is still able to show the part of the page while it is still loading the page.
Thanks in advance
Kajol
Asynchronous ADO Execute
I am trying to do an asynchronous execute of a stored procedure (client side cursor). I do not want the recordset back. It works fine. But if I can't quit my program as I get this asynchronous call is still executing or something like that.
Is there any way to avoid this?
Thanks a lot.
Asynchronous Calling Of Exe
Hi all,
I got a vb program(Main.exe) which will keep on invoking exe(s) according to the task list stored in registry. After each exe finish executing itself, Main.exe will have to write something back to registry. My question is how can the main.exe keep invoking exe(s) while keep writing to registry after each exe finish its execution? Any API needed?
Thanks.
Asynchronous Recordsets With ADO
I have an application that retrieves a large recordset (c. 100,000 rows) using adAsyncFetch. I populate a grid with the first 'screenful' of rows when they have returned. I have a separate scrollbar control to window the static grid onto the recordset. The recordset is on a Client cursor (adUseClient) which is static.
What I'm after is a way of telling how many rows have been put into the recordset so far. I want to use this information to resize the scrollbar.
I've declared my recordset WithEvents and tried using the FetchProgess event, but I always get Progress of 0, MaxProgress of 1 until the whole recordset is returned. At which point Progress becomes 1.
I've also tried accessing the .RecordCount and .PageCount properties of the recordset but they are only populated when the whole recordset is returned.
Is there any property or method I can use to determine how many rows are in the recordset so far? Or is there a setting I need to enable to give me visibilty of the information in the appropriate property before all the data is back?
ADO And Asynchronous Execution
I've been trying to use the adExecuteAsynch option on one of my ADO commands and VB doesn't seem to recognize the constant. What's up? How do I get my recordset to keep on returning while continue on in the code?
Make A COM Asynchronous...
I have one question.
I'm using an activex dll from an ASP page, is there a way to let the process go before it's actually done?
I mean, I can let my dll run in background and don't make the ASP wait for it to end its process..
Thank you.
Asynchronous Progressbar
Looking for a way to create a progressbar that will run asynchronously. Need the progressbar to run on its own (in its own form) until it is stopped upon completion of the other process.
I have tried the SetTimer API but something is causing the Interval not to fire (which in turn is not updating progresss on the bar). Any ideas???
Asynchronous Printer Notification
1. The print watch server
Use FindFirstPrinterChange and WaitForMultipleObjects to wathc for changes on the selected printer(s) and send a registered windows message when such occurs.
(See the inter process communication article for how this works)
Asynchronous Program Running
Hello,
I call another executable file within my code, however, i need to use the output of that programs' execution for my program. is there any way to stop the asynchronous running of the programs? forgive me for my lack of terminology. basically, i want to pause the execution of my program until the executable file that i call stops running so that i can use the output.
thank you,
keli
Shell Asynchronous Question
I'm looking into running a decryption program using the Shell function in VB but after looking in the MSDN Library I encountered this quote:
"Note By default, the Shell function runs other programs asynchronously. This means that a program started with Shell might not finish executing before the statements following the Shell function are executed. "
I must use the shell to decrypt the files in a directory before I try and open the decrypted files. But if this article is right I can't be sure that the shell will be done before I move on in my code. Could someone with more experience using the shell let me know if there is a way to force the shell function to finish executing before the next line executes. Maybe something like
Do While Shell.Busy
Doevents
loop
Thanks alot
Asynchronous FetchProgress Halt
I'm trying to halt a query if it runs greater than a given # iterations/steps. I thought I could use the FetchProgress event and and simply watch the progress, if it exceeds some number I could stop the query using adStatus = adStatusCanel. This (adStatus = adStatusCanel) works until I set the cursor to the client, and then no workie. Unfortantly, I have to have the client cursor for the fetchprogress to work. Any help here would be greatly appreciated!
VB 6.0
ADO 2.8
SQLServer Express
Code:
Private Sub rs_FetchProgress(ByVal Progress As Long, ByVal MaxProgress As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Debug.Print "Fetch: " & Progress & " Max: " & MaxProgress
If Progress >= 500 Then
adStatus = adStatusCancel
End If
End Sub
Asynchronous Query Execution
Hi! I have a program that executes some SQL queries and fill MSHFlexgrids.
Sometimes that queries have so much information that the process takes a lot to fill all the grids.
I wonder how to execute a query asynchronously (sorry my english!) in order to have a command button that can be clicked to cancel the current execution...
Am i clear? sorry my english again!
Thanks in advanced
Asynchronous Web Functiuon Call
I have an application which grabs stock quotes, essentially constantly, from the web. My source occasionally ( too often ) gets locked up and fails to return from the call for sometimes minutes, when the normal time is milliseconds for hundreds of results. I have tried several iterations to allow my program to abandon the calling loop when the response is slow, but nothing has been an improvement. The final function call is in a custom object as follows:
Public Function GetQuote(Symbol As String) As QUOTERECORD
Dim RealTime As QUOTERECORD
' DoEvents
RealTime = RT_Quotes.GetCachedQuote(Symbol)
'DoEvents
GetQuote = RealTime
End Function
This function is driven by a loop with a few hundred symbols, and when a single call stalls, I need an elegant way of releasing from the loop until a later try when things are better. I have put DoEvents in many places to no avail, and I have a response timing tick counter that will bail out of loop when response exeeds X milliseconds, but if one delay is excessive, my program is essentially hung because it can't get to my escape logic.
Any good solutions to this?
Thanks in advance
ASynchronous Wait Function?
Ive got like 50 winsocks on my form, each independant of each other. say i get some data received in _DataArrival that needs me to send something back in 5 seconds for ONE particular winsock.
how can i do it?
or lets say im downloading files thru a webbrowser control, and lets assume i cant use the downloadcomplete/documentcomplete events for whatever reason
normally id do something like
do:doevents: loop until wb.busy = false
but this hangs my entire app. can i just just do something like..
wb.navigate "mysite"
StartASyncTimer 'timer will check the wb's status and can execute code if the wb's state is where i want it to be
anyone know?
Asynchronous Wininet APIs
Hi there !
I want to download multiple files at the same time using the
URLDownloadtoFile Wininet api function.
Now i found the following article from microsoft
it says about how to asynchronously execute many Wininet api functions at the same time.
Has anybody implemented this stuff or do you know any source code that has implemented this ?
thanks !
http://support.microsoft.com/default...NoWebContent=1
Asynchronous Comms - Serial API
Hi,
I am using a Class Module to use Serial Communications and Win32 API. I need to Wait on an Event outside of the main operation so that the class module does not wait. Baically I need to do the wait operation in a different thread. I know you cant multithread (worker threads) in VB. Should I create another class module to perform the operation and callback using events or can someone suggest a better way.
Thanks.
MechEngCoder
Asynchronous Validation Problem
I've got text field that you can input the date in. In either the Validation function, or lostFocus function (I've tried both), I error-check to ensure a proper date, and if not I fire a msgbox.
But if the user decides to click a button on another form, a run-time error occurs indicating that you can't show a non-modal form when a modal form is displayed.
The msgbox then pops up AFTER the run-time error. So VB is calling the Cmd_click on the other form item, before it validates/calls lostFocus on the text field.
Is there some elegant way to prevent this from happening, or am I just forced to use a boolean and set the flag everywhere I go?
Asynchronous Winsock... Delimiters?
Hi
I'm coding some client/server application that use Winsock.dll... I'm using WSAAsyncSelect to determine the arrival of some data, and using this way, I sometimes receive a bunch of data... For example, my server send three string of data, with three different instructions... it fill the buffer and send it after... So I receive, let's say "abc" instead of receiving each letter one after one... What do you think I should use? Delimiters? Or some length-prefixing bytes? Or is there a way to force normal data arrival? Thanks a lot
Asynchronous Thread Controls
Hi,
am playing around with workerthreads in vb.net 2003
I made a small project for testing that i uploaded
in my solution i got 2 projects; 1 for a form and 1 for threadlogic(businessclass if you will)
i was wondering if anyone could tell me if this way of updating the controls is 'allowed' because i'm reading everywhere you're not allowed to set a control in a thread (one which didn't create the controle). Although it seems to work.
The reason im asking is because the helpfile on ISynchronizeInvoke.Invoke it clearly says;
First parameter = A Delegate that contains a method to call, in the context of the thread for the control
Also in the OnComplete-methode i'm having trouble;
Dim dhw works i can't seem to declare the type (invalid cast) because the delegate is in the form-project (i tried copying it into the class but doesn't work, setting a reference to a form-project is not allowed). Anyway around this??
Further i wanted to ask if a reference to system......forms is common in a project that handles threads.
tnx in advance,
Jannick
ps: i just saw/tested my attachment and forgot to mention; open project testingthread and delete the 2 components that arent found ( clsTest and frmMain)
Edited by - jannick on 3/7/2006 1:02:25 PM
Asynchronous Wininet HTTP
Im totally stressing over this, im trying to asynchronously retrieve files. C++ Disassembler returns this error for the illegal operation the following code generates.
Quote:*** Wininet Assertion failed: dwStatus != INTERNET_STATUS_REQUEST_COMPLETE
*** Source file: e:
1inetcorewininetdll hrdinfo.cxx
*** Source line: 1514
*** Thread fffdb5e1
Code:Dim hOpen As Long, hOpenUrl As Long
hOpen = InternetOpen(App.Title, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, INTERNET_FLAG_ASYNC)
Call InternetSetStatusCallback(hOpen, AddressOf StatusCallback)
hOpenUrl = InternetOpenUrl(hOpen, "http://www.google.com/index.html", vbNullString, 0, &H80000000, 0)
Call InternetCloseHandle(hOpenUrl)
Call InternetCloseHandle(hOpen)
Declarations
Code:Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Public Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hOpen As Long, ByVal sUrl As String, ByVal sHeaders As String, ByVal lLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Public Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Public Declare Sub InternetSetStatusCallback Lib "wininet.dll" (ByVal pub_lngInternetSession As Long, ByVal lpfnInternetCallback As Long)
Public Const INTERNET_STATUS_RESOLVING_NAME = 10
Public Const INTERNET_STATUS_NAME_RESOLVED = 11
Public Const INTERNET_STATUS_CONNECTING_TO_SERVER = 20
Public Const INTERNET_STATUS_CONNECTED_TO_SERVER = 21
Public Const INTERNET_STATUS_SENDING_REQUEST = 30
Public Const INTERNET_STATUS_REQUEST_SENT = 31
Public Const INTERNET_STATUS_RECEIVING_RESPONSE = 40
Public Const INTERNET_STATUS_RESPONSE_RECEIVED = 41
Public Const INTERNET_STATUS_CTL_RESPONSE_RECEIVED = 42
Public Const INTERNET_STATUS_PREFETCH = 43
Public Const INTERNET_STATUS_CLOSING_CONNECTION = 50
Public Const INTERNET_STATUS_CONNECTION_CLOSED = 51
Public Const INTERNET_STATUS_HANDLE_CREATED = 60
Public Const INTERNET_STATUS_HANDLE_CLOSING = 70
Public Const INTERNET_STATUS_REQUEST_COMPLETE = 100
Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Public Const INTERNET_FLAG_ASYNC = &H10000000
Public Sub StatusCallback(ByVal hInternet As Long, ByVal dwContext As Long, ByVal dwStatus As Long, ByVal pbStatusInformation As Long, ByVal dwStatusInformationLength As Long)
Select Case dwStatus
Case INTERNET_STATUS_RESOLVING_NAME
Case INTERNET_STATUS_NAME_RESOLVED
Case INTERNET_STATUS_CONNECTING_TO_SERVER
Case INTERNET_STATUS_CONNECTED_TO_SERVER
Case INTERNET_STATUS_SENDING_REQUEST
Case INTERNET_STATUS_REQUEST_SENT
Case INTERNET_STATUS_RECEIVING_RESPONSE
Case INTERNET_STATUS_RESPONSE_RECEIVED
Case INTERNET_STATUS_CLOSING_CONNECTION
Case INTERNET_STATUS_CONNECTION_CLOSED
Case INTERNET_STATUS_HANDLE_CREATED
Case INTERNET_STATUS_HANDLE_CLOSING
Case INTERNET_STATUS_REQUEST_COMPLETE
End Select
End Sub
There doesnt seem to be much info on wininet api in vb
Edited by - Daniel on 8/9/2003 2:29:20 AM
|