Function Accessed By Multiple Threads With Parameter Passed By Reference
Apr 29, 2011
I am in vb.net and have a function that will be accessed by multiple threads. Everything inside the function uses local variables. However, each thread will pass in its own dataset by reference. From what I have read the local variables should be no problem, but I think the dataset coming in is a concern. How should I control access / execution of this function to make sure that it is thread safe?
View 1 Replies
ADVERTISEMENT
May 1, 2011
Is there a way to write a single function that will control validating the input to any textbox? How to pass control of it.
E.g.: My second try was to:
Dim CurrentTextBox As TextBox << Declare a global
Write a function that uses the global textbox and takes in 2 parameters, one determining the length it has to validate and the second telling it what to do once the input is verified
Public Sub ConfirmInput(length As Integer, which As Integer)
If (CurrentTextBox.TextLength < length) Then
CurrentTextBox.BackColor = vbRed
GoTo DONE
ElseIf (CurrentTextBox.TextLength > length) Then
CurrentTextBox.BackColor = vbRed
[Code] .....
My first try was to pass a textBox parameter to the ConfirmInput function but I believe that's the same problem as above.
View 4 Replies
Sep 7, 2011
i need to create multiple threads to improve a function on my program. it is a simple thing really but it's slow and if multithreaded it can improve the speed some thousand times. my program uses a dll to check the MX record of an e-mail from a textbox called emails if the mx record is correct then it validates that domain, if not, it sends to an error textbox with that mail my problem is that im reading a lot on multithreading and i dont have an idea how to make something like this: for x=0 to emails.lines.count -1' start a thread that runs my function next if i can limit the number of threads to avoid crashing it would be good.
View 5 Replies
Sep 23, 2008
The case is that I have two comboboxes (country and state) and a simple code to populate the state combobox accordingly depending on the selected country. Ok this is simple and easy, and this code is within the country combo change event.The case is that I have more than one pairs of those comboboxes and I wouldnt like to repeat all the populate code into every country combo change event.Actually I would like to have only one function and just call it passing as parameter a reference to the combobox I want to populate. Then I could use that reference into the function.
View 10 Replies
Mar 23, 2012
I want to pass a List of T where T is an object I've created that has about ten properties (strings, dates and integers).The lst passes to the function successfully. I am also passing an New T of the Object (itm as T).I can see all the values (see image below), but because it's generic I cannot seem to retrieve the property values and I cannot figure out how to iterate through the properties of each itm as they are retrieved in the For Each.[code]
View 10 Replies
Mar 1, 2009
I have a method which requires a parameter to be passed in. I would like to use the Addhandler to call the method through a dynamically created button control's click event.
When I include () in the AddressOf, VS complains: 'AddressOf' operand must be the name of a method (without parentheses).
When I exclude the brackets, VS complains: Method '...' does not have a signature compatible with delegate...
My code:
CODE:
View 5 Replies
Oct 19, 2011
I just had a new, last-minute idea on to take on a task, so I am running to StackExchange for quick help.
What I want to do is execute a series of methods right in a row, each in their own threads. I want the application to wait until all of these threads are completed, after which the program will resume. It also has to use managed threading (thread pool).
What quick examples could you provide to help me along the way? If it's too complex, what things should I know about so that I can Google it on my own?
View 1 Replies
Oct 19, 2011
I need to pass in parameters to my sub/function. When the parameter is passed, the value in the string, I would like to get the value evaluated and sent as:
Dim strParams As String = drRow(0)
' drRow is a row from DB Table. the value in drRow(0) =
' "@FromDate=""" & Now.AddDays(-10).ToShortDateString & """&@ToDate=""" &
[code].....
View 2 Replies
Nov 27, 2009
The parameter to a sub is being passed a value like 501/500, of coarse this value should be converted to 1.002. Unfortunately, the actual value being passed to the parameter is 1.0.
[Code]...
View 2 Replies
Aug 29, 2011
How can I get the name of the object that was passed byref into a method?
Example:
Dim myobject as object
sub mymethod(byref o as object)
debug.print(o.[RealName!!!!])
end sub
[code]....
I'm using this for logging. I use one method multiple times and it would be nice to log the name of the variable that I passed to it. Since I'm passing it byref, I should be able to get this name, right?This would give you the parameter name in the method and it's type, but not the name of the variable that was passed byref.
using system.reflection
Dim mb As MethodBase = MethodInfo.GetCurrentMethod()
For Each pi As ParameterInfo In mb.GetParameters()
[code]....
If you put that in "mymethod" above you'd get "o" and "Object".
View 3 Replies
May 2, 2012
If the parameter variable is not passed then this code throws an exception of "Conversion from string "" to type 'Date' is not valid."
This is my code.
Public Shared ReadOnly Property Request_projectStartDate() As Date
Get
Dim _value As String = Nothing
[Code] .....
View 2 Replies
Feb 14, 2011
say I have two POCOs I'm using in EF code first
Public class C1
property F1 as integer
End Class
Public class C2
property F2 as String
End Class
I want to have a function that will create a list either of C1 or C2, to be used in some generic operation, such that
[Code]...
View 1 Replies
Feb 2, 2012
I m struggling in setting the Value in List Picker to be the one I want.
I have that in xaml
<
DataTemplate
x:Key="ListPickerED">
[Code]....
View 2 Replies
Oct 28, 2011
I am working on a little program (game) is called Pig latin. I created a sub procedure and I passed the word to be converted by value and the piglatin word byref.Now when I call the procedure in the button click event I get the wavy green line under the variable passed by reference but the program works ok. Call Convert_to_Pig_Latin(strOriginalWord, trPigLatinThe error message when I hover my mouse over the green line says " Variable strPigLatin' is passed by reference before it has been assigned a value. A null reference exception could result at runtime."
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
[code].....
View 4 Replies
Aug 6, 2010
I've searched a lot on both google and here but sorry, couldn't find.Maybe I'm just asking the wrong question, so I'll try to explain it here to see if someone can help me:
what I'm trying to do is what in C would be as simple as int varptr = &var I have a form that is just a communication watcher/logger. It's just a blank text box with a Pause/Play button and a copy to clipboard button and every new activity on my serial communication is logged. At the moment the form have a timer that once a second do textbox.text = serial1.log ...
but the problem is that I also have serial2; serial3; sql1 that I would like to keep an eye on them, and considering my work here I'm sure I would be re-using this form a lot if I could make it portable. Create one form for each is just stupid, as you'll all agree.
Then I would like to have an sub initialise(byref log as string) that would store this reference into an local variable within the form; so that every new instance of my form could be initialised with whatever log they'll be looking for and the timer just make textbox.text = LogPointer to the actual value of the log string.So, as I said I really wanted a int varptr = &var
View 4 Replies
Jul 7, 2008
Im getting the Variable (Data) is passed by reference before it has been assigned a value error.
[Code].....
View 3 Replies
Oct 15, 2009
I want some event handling functions to only be able to be accessed via raised events and not called from the program.[code]...
Is there a declaration or some other way to accomplish this?
View 2 Replies
Mar 9, 2011
I want to have a "template" function that can receive different parameter and a type parameter, like:[code]But Vb told me that tupeList is not defined... is there a way I can do that?
View 2 Replies
Jun 7, 2012
I have an application that I made in VB.NET. I put it in the server on my office and every other user access it via network connection. I only mapped the drive onto their computer and then I cope the shortcut to the application. can I close all the application that is running with a single code? I sometime need to close all the application first before I can do anything with the application (for example, modifying the report etc.). My current method is still the manual one, which is calling everyone to close their application or running all over the place closing the application myself.
View 1 Replies
Sep 15, 2011
I have a loop that creates several threads as such[code]...
View 1 Replies
Nov 12, 2009
I'm not having any errors from these pieces of code, they're just empty everytime. I'm wondering if I perhaps have created them incorrectly.
Dim l As New Log()
l.Log = "Attempted staff login with username [" & txtUsername.Text & "]"
l.LogId = 0
l.StaffId = 4
l.LogDate = Date.Now()
l.Insert()
.Insert() is picked up in my BLL layer by these two functions;
[Code] ......
View 2 Replies
Nov 26, 2009
ok basically i've got a delegate ByVal function_to_execute As dele0 but instead of invoking it, i wish to add it to an eventhandler
Public Sub test(ByVal function_to_execute As d0)
Dim t As Timer = New Timer()
AddHandler t.Tick, AddressOf function_to_execute.address
[code].....
View 4 Replies
Jun 7, 2011
I need a 2 functions:
1)the first that alert me when one month is passed ex: 25 december 2011 - 25 january 2012
2)the second that alert me when one week is passed ex: 25 december 2011 - 1 january 2012
View 3 Replies
Jul 2, 2009
Is there a Limit to the parameters that can be passed byVal or byRef to a function or procedure in vb .net ?
[URL]
View 2 Replies
Sep 20, 2011
My issue is regarding overloaded functions of the already provided IIf function that would handle specific types. As you all know the IIf function provided returns objects, rather a specific type so for my needs I created a few overloaded function to do just that but with a specific type in mind. So having said I have IIf functions for types of booleans, strings, bytes, integers, etc etc.
Now my problem is when I'm trying to pass a byte value to this function that would return one of the two byte values. When I do this the designer keeps confusing my values as an integer value and calls for me to convert it to a byte. If I did this then it would defeat my entire purpose for creating these functions-which is to avoid any conversions. The only way I can solve this is by converting the whole statement itself or the true/false parameter parts individual to specify to the designer that these values are bytes. I'm just hoping there's a way of identifying the difference between bytes and integers..
View 12 Replies
Oct 24, 2009
I have made a Windows Service program called InvCheckService.exe. I am passing the working folder using the Services Property for this program. I am putting the parameter "D:Inv" into the "Start Parameters:" textbox.In my program I am getting 1 parameter. Its is D:MyServicesInvCheckService.exe which is where I ran the InstallUtil.exe from.
Here is the code for the OnStart Subroutine:
Protected Overrides Sub OnStart(ByVal args() As String)
Dim parms() As String = Environment.GetCommandLineArgs()
Dim msg As String = ""
[code]....
View 2 Replies
Jan 26, 2012
I'm trying to convert an old ASP.Net 1.0 application to ASP.Net 3.5 and am running into trouble with a JavaScript function. The application passes in content into an within a table cell. The function is supposed to calculate the height of the content and size the table cell appropriately.
way of accomplishing this with the
JavaScript function
<script language="javascript" type="text/javascript">
<!--
function calcHeight() {
[Code].....
View 1 Replies
Sep 28, 2011
I wrote a Log class that details the exception, including the method name and its arguments list,but I couldn't find any way to programmaticly retrieve the arguments values.in some forums it was said that its impossible mission. I find it very odd.my arguments list looks like:
argA As String = ?
argB As integer (Opional, Default value = 2) = ?
etc. only actual values are missing.
View 9 Replies
Dec 13, 2011
I need to execute a stored function in oracle or sql through vb.net. I created a command object. Depending on the database type(oracle or SQL) i am preparing the Command text as Select functionName(?,?,?,?,?,?,?,?) from dual; (For Oracle) Adding the parameter values of the function. Now performing the ExecuteScalar which is not working saying invalid parameter. This works with ODBC connection string. But ODBC doesn't with 64bit. My Requirement: Code should execute a user defined stored procedure by taking the values at runtime.
View 1 Replies
Oct 4, 2011
I'm making a IM LAN Chat, and I don't want to limit it to a specific number of chats that can be open at any given time (By re-producing the forms and setting variables once a chat is open).
[Code]...
View 4 Replies