How To Return Variable From Thread

Mar 10, 2009

This is my simple code that calls a function from a class I created called "clsNetwork". The function simply pings a computer from a computername I pass it and returns the results.

Dim PingStatus As String
PingStatus = clsNetwork.PingComputer(ComputerName)
txtbox.text = PingStatus

View 13 Replies


ADVERTISEMENT

Thread Communication - Return The Information Back To The UI Thread?

Feb 20, 2011

I'm using webclient to download a webpage but obviously since it's on the UI thread it freezes.How can i change my class to be multi threaded using DownloadStringAsync? i can do this normally but since i am needing to return the information back to the UI thread i am a bit stuck

Public Class RequestExecutableInformation

Public Function FileReport(ByVal executable As String, ByVal ParameterStart As String, ByVal ParameterFinish As String) As String

Dim Source As String = String.Empty[code]...

View 6 Replies

Thread.Join Does Not Return With Quitted Thread?

Nov 9, 2011

in my Winforms application, there is a main thread. It is not the UI thread but it starts the UI thread. In the main thread, I'm using a Mutex to prevent the application from being started twice. That's why I'm making an exception from the rule not to use a Thread's Join method. In this case, the main thread does call UIThread.Join before releasing the Mutex. That works well.

The strange problem is: Whenever an exception occurs in the UI thread, the default Windows error dialog pops (send report, debug, close). If I select "close", the application does not quit. Instead, the main window (created in the UI thread) stays visible, but it is inoperatable. It looks as if the UI thread still does not quit, and consequently the main thread's call to UIThread.Join doesn't return either.

Though, if I debug the application at that point, the "threads" window does not show the UI thread anymore. I've given it the name "UI Thread" (surprisingly).So, why does the Join method not return even if the thread has died? Why is a window of a died thread visible?The following screenshot shows the Threads window below and the window above shows the callstack of the main thread ("Hauptthread").

View 7 Replies

Return A Value From A Thread?

Oct 17, 2009

I tried to make a thread (address of function) , but vb.net didn't accept that.

is there any way to return a value from a thread ?

View 2 Replies

Backgroundworker Return Value To Another Thread?

May 2, 2009

I am using a class with below code, the question is how to update the label's value at UI thread from the backgroundworker?

Imports MySql.Data.MySqlClient
Public Class clsBackGroundWorker

[code]....

View 7 Replies

VS 2008 Return Results From Function Run In A Thread?

Feb 3, 2010

I am running a query in a thread but I can't figure out how to get the result back to the calling function. I am doing something like this:

Threading.ThreadPool.QueueUserWorkItem(AddressOf RunThread, "some query string")
Private Function RunThread(ByVal stateInfo As Object) As String
Dim myQuery As String = stateInfo.ToString

[Code]....

View 3 Replies

Checking The Return Code Set By A Task / Thread / Process / Program?

Apr 16, 2010

A long time ago, on a PC far, far away from Windows, one MS-DOS program (the father) could run / execute / spawn another MS-DOS program (the son). When the son terminated, it could set a return code which could certainly be interrogated by an MS-DOS batch program or, I think, by any father program that invoked it (depending on the language in which that program was written). I have a small utilility which I want to invoke from my application, and, since that utility sets a return code, I would like to interrogate it in my application when the utility terminates. I've looked through the MSDN Library but could not find anything that seemed to cover this situation. Is there a way to do this in Visual Basic 2008 Express

View 2 Replies

Get Variable Value From Thread

Feb 1, 2011

I have a thread create by the Threading Namespace.This Thread is doing some work an is waiting in a loop for new information.Now I want to get a value from a public shared variable out of the thread.

View 5 Replies

How To Get A Variable/value Out Of A Thread

May 28, 2010

I want to write some code to do some processing. This seems best done in a thread. But I also want some UI and general controlling passed to and from it. eg: Adding lines to a text box for general UI updating while it's running.Now, let's assume I might have multiple threads running, so each thread can call my UpdateUI subroutine. But the problem is, at the moment my code is using a public variable UI_Msg to pass values back from each thread to the UpdateUI subroutine. This hits me as dangerous as different threads may overwrite UI_Msg at the same time.Instead I tryied to attach a class to each thread, so each thread has its own UI_Msg property/value. When I then get to UpdateUI, I want to pluck this value out of that thread, so there's no risk of different threads overwriting each others msgs to UpdateUI.

Imports System.Threading
Public Class MainForm
Public UI_msg As String

[code].....

View 7 Replies

How To Return The Variable Name Itself

Dec 10, 2010

1. How to return the variable name itself? Public Class test Public Shared as String = "111" End Class I want to return AAA but no 111, test. = "111", and test. Tostring = "111"

2. I want to join the space char into the variable, for example A B but no AB, how to do?

View 7 Replies

Asp.net - SQL Select Return Value To Variable

Sep 14, 2009

working with: ASP.net using VB.net connecting to MS SQL Server

What I'm trying to do is take the result of a SQL select query and place that in a string variable so it can be used in things like a textbox or label. code so far that doesn't work...

Imports System.Data.SqlClient
Partial Class dev_Default
Inherits System.Web.UI.Page
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)

[Code].....

View 3 Replies

VS 2010 - Send Variable To Sub On New Thread

Jun 12, 2011

I have created a class with a public sub which has a variable with it using byval:
Public Class clsMessenger
Public Sub Messenger(ByVal Port As Integer)
End Sub
End Class

I now need to start that sub in a new thread and pass a varible to it but I am not entirly sure how to go about that. At the moment I have:
Dim ClientConnection As New clsMessenger
Dim ClientThread As New Threading.Thread(AddressOf ClientConnection.Messenger)
ClientThread.Start()

I can't use a global variable because there is going to be multiple instances of this routine running on different threads and each time the variable to be passed will be different.

View 8 Replies

Making An Object Return Its Own Variable Name?

Dec 10, 2009

I was wondering if there's a way I can make my objects return their own variable name as a string, something like this:

Public Class MyClass
Public ReadOnly Property VariableName() As String
Get

[Code]....

Is this possible? I'm fairly sure it should be possible through the System.Reflection namespace, but I can't figure it out.

View 7 Replies

Return Class Variable On Form?

Jan 27, 2010

I wrote the following two functions in a class to take a gpib reading and also take a measurement from an LCR meter.
HTML
Public Function gpibRead(ByVal Channel As Integer, ByVal buffer As Integer) As String
Dim readingBufferA1 As String
Select Case Channel
Case 1
readingBufferA1 = gpibLCRA1.ReadString(buffer)
Return readingBuff
[Code] .....
When on the main form I call the funtion takeMeasurement(1) how can I get the LCR readings back. If I try and use readingBufferA1 on the mainform it doesn't recognize that as a variable. I know that it is taking the reading and storing the correct numbers because I am monitoring on NI Spy.

View 6 Replies

Use Function Return In Global Variable?

Jun 3, 2010

Can't seem to figure out how to use a function return variable in global Dims[code]...

I have also tried adding "FixPath()" under Sub On_load() but got same result. Also the reason I have to have these global is because I have around 30 Subs that refer to "Path" Variable.

View 1 Replies

VB 2008 - Return A Variable Using The Function

Jun 17, 2010

I am writing a program with multiple forms (for inputing loan/financial information - so they are set up exactly the same albeit a form number (ie: 1-6)) that feed into a summary page form to display each individuals form's information. When the user closed a financial form, it then feeds the information to a summary page using the code I have below: [Code]. I am new to working with functions, and have not been able to find anything that can show me how to fill multiple textboxes with them (I only know how to return a variable using the function to work a calculation). Any way that I can write a function (or any other call) for this would save me a tremendous amount of coding, and make debugging worlds easier.

View 3 Replies

VS 2008 Return Variable From A Webpage?

Apr 7, 2009

excuse my stupidness, i'm fairly new to VB and i've only done a little bit with it before. Basically i am making a little application that i want to run on my machine. Standalone not via a web browser.I have a web page which is generated using php, there is no html code on the page simply a number, e.g. "9995" when you view source.

All i want to do is return this value from the web page (without actually opening the page in a browser) and display it in a text box in VB or store it as a variable that i can use later. point me in the correct direction or right keywords to research, or if you have a simple example that would be even better

View 10 Replies

How To Handle Variable Type (parameter & Return Value)

May 25, 2011

Is it possible to replace these two functions

Function f1 (s As String) As class1()
Dim a() As String = Split(s)
Dim b(UBound(a)) As class1

[code].....

View 3 Replies

Return A Variable Based On The Input Of A Function (.NET C# Or VB)

Apr 12, 2012

Say I've got the following variables:

Public Shared x As String = "100"
Public Shared y As String = "text"
Public Shared z As String = "something"

[Code]....

But this doesn't do what I want, naturally. What I want is that my function giveVar returns the value of the variable that holds giveVar. For example I call giveVar("x") I want my function to return "100".

Of course this can be done by a Select Case but thats not what I like to do. Is it even possible to call a value based on a string?

[edit:]

Namespace i18n
public NotInheritable Class Settings
Public Shared LanguageCode As String

[Code]....

I think this works so far, BUT I get the following error on the CallByName(Me, varName, vbGet) at the Me : "me is only valid within an instance method"

View 5 Replies

Return A Variable To A Text Box Via Cursor Location?

Jun 10, 2010

I am building a GUI for a touchscreen panel using VB2008 and am trying to set up a password change screen. I have an on-screen keypad set up so the operator can use it to enter the new/old password. How do I return the value from the key pressed to where the cursor is located?

View 8 Replies

Socket Return Breaking String Variable?

Feb 20, 2012

When trying to register a new user on the server, the server will post back messages such as "OK" and "usernameTaken". Upon comparing this returned string with another string (to perform an action based on the returned value), the compare isn't working.

Dim backupX As New CBackup
backupX.startSocket("127.0.0.1", 8888)
Dim str1 As String = backupX.registerUser("user1", "testpass")
Dim str2 As String = "usernameTaken"

[code]....

Looks to be like the socket code is working just fine.. each Function returns the corresponding Functions' Return value (registerUser -> SocketSendAndReceiveMSG -> sendAndReceiveMSG -> receiveMSG).

View 1 Replies

VS 2008 : Return/save The Value In A Variable - Button?

Jun 25, 2011

When i press the button3, i want the webbrowser change site after how mutch the clock is. Is the clock between 9:00 and 17:30, the webbrowser is gonna change to swedish sites. If the clock is between 17:31 and 21:30, the webbrowser is gonna changes to american sites. But the webbrowser is only choose ONE swedish site and ONE american site. The problem is that the variable b does not save the value it has before.How to i make so the variable b saves the value it has before? b = b + 1 is gonna be first 1. Then if i press the button3 agin, it gonna be 2. and if the value is 3, it gonna be 1 agin.

PHP
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim changesSE(3) As String
Dim changesUS(3) As String

[code]....

View 1 Replies

Debug Calculated Function Returns Without A Return Variable?

Jul 13, 2010

It's often the case that I can write a nice tight little VB.NET function, and when it comes time to do the Return statement, it's really natural to just return the result of a quick calculation or a method call. However, this makes it difficult if I need to step through the debugger to see what is going to be returned from that Function. For example, take this simple method to illustrate the concept[code]...

View 3 Replies

Custom Function Return Type + Input As Variable Datatype?

Dec 1, 2010

I'm wondering whether its possible to have a function's return type and input arguments as a variable.

For example this function:Private Function MyFunction(ByVal argument1 As VariableType) As VariableType

[Code]...

View 6 Replies

Gained By Using The Function Itself To Hold The Return Value Instead Of Declaring A Local Variable?

Oct 28, 2010

What's best practice (in VB.Net):

Function GetSomething() as String
GetSomething = "Here's your string"
End Function
or
Function GetSomething() as String
Dim returnString as String = "Here's your string"
Return returnString
End Function

Obviously, neither of these implementations make any sense, but they're just meant to illustrate my point. Is there anything to be gained by using GetSomething itself to store the return value instead of declaring returnString locally and then returning that (does it avoid having an extra string allocated/instantiated - and if so, are there any performance/memory benefits)?

View 6 Replies

VS 2010 Error - Cross-Thread Operation Not Valid: Control TbPlaca1 Accessed From A Thread Other Than The Thread It Was Created On

Aug 13, 2010

In one application, I need use 4 simultaneous threads.When the threads finished, I need to update the text of a TextBox.So, I create 4 Textbox, and I wanna the threads change the text to FINISHED.Each thread change one distinct TB.I use this "example"

Dim Terminados As Integer = 0
Private Sub frmEnviarMensagem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer1.Start()

[code]....

The problem is, I have an error in the red lines.The error is: INVALIDOPERATIONEXCEPTION "Cross-Thread operation not valid: Control tbPlaca1 Accessed from a thread other than the thread it was created on."I don't use cross threading. Each TB only was accessed for the correspondent thread, and for the "main program".

View 3 Replies

Cross-thread Operation Not Valid: Control 'Panel1' Accessed From A Thread Other Than The Thread It Was Created On." ?

Nov 3, 2011

This is the error message I am getting:

"Cross-thread operation not valid: Control 'Panel1' accessed from a thread other than the thread it was created on." The reason I am getting this error is because I am opening up a new form and then calling these three things:

Panel1.Show()
Label1.Show()
Label2.Show()

why I get this error message because it doesn't occur normally if I open Form2 after closing Form1, it only occurs when I open Form2 after closing Form4.

View 4 Replies

Error - Cross-thread Operation Not Valid: Control 'txt1' Accessed From A Thread Other Than The Thread It Was Created On

Jul 21, 2009

I have done a program using vb2005 to display reading from my microcontroller bs2 board but have encountered some problems. My code are as follows.

Dim Stop_Rx As Boolean
Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
SerialPort1.Open()

[code]....

I've encounter an error which is, (Cross-thread operation not valid: Control 'txt1' accessed from a thread other than the thread it was created on.)

View 7 Replies

Error : Cross-thread Operation Not Valid: Control 'l_users' Accessed From A Thread Other Than The Thread It Was Created On

Jun 21, 2012

When my client try to connect to server I'm getting this error : Cross-thread operation not valid: Control 'l_users' accessed from a thread other than the thread it was created on.

Private Sub _socketManager_onConnectionAccept(ByVal SocketID As String) Handles _socketManager.onConnectionAccept
l_Users.Items.Add(SocketID)
End Sub

View 3 Replies

Threading Progress Bar In .net - Thread Operation Not Valid Control 'ProgressBar1' Accessed From A Thread Other Than The Thread It Was Created On

Feb 17, 2012

Would anyone be able to help me here please. I'm fairly new to VB.net and threading so im just trying to figure out what is happening.When I debug this I am getting the error thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on.

I'm a little lost as to why the error is occuring or how to fix it. I've had to put the progress bar in a separate thread otherwise the GUI crashes

[Code]...

View 2 Replies







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