|
The application don't open and close sockets all the time: in fact, it just open and keep them opened. I must use different sockets to send and receive data.
I have one thread per "send" socket. The "send" sockects are awalys opened and send data indefinitely, as long as it arrives in his own queue. There are 2 to 10 sockets like this being used at the same time, so 2 to 10 threads always active sending whatever arrives on the queue (separate queues).
The "receive" sockets (one for each "send" socket) works using the OnDataArrival event. I suppose they use thread pool threads to fire the event.
Anyway, I agree that what I need is a complete code revision to avoid memory leaks and some multithreading review too. The sockets doesn't seen to be the real problem. For example, there are too many "controls" over the queues, using some could-be-avoided multithread. I'll work on that direction.
Does anyone know if the Enterprise Library can have something to do with this? It has been used to log some data in a sql server database.
Thanks everyone for the support.
Regards,
Leonardo Muzzi
|
|
|
|
|
Leonardo Muzzi wrote: I must use different sockets to send and receive data.
Why don't you use the same socket for sending and receiving data? IMO, you only need one server socket and it should be able to handle the connection and send/receive. Avoid creating unnecessary threads. Prefer asynchronous methods over the synchronous one.
Leonardo Muzzi wrote: Does anyone know if the Enterprise Library can have something to do with this?
Not sure.
|
|
|
|
|
'Cause they are really different sockets. Diferent ip/port combination, different connections. The legacy application that answers to these sockets on the other side works like this. And I believe this is better , 'cause this application can receive many requests at the same time. Otherwise, it would block the connection until it gets the answer.
I use the OnDataArrival event to receive the data, that is, assyncronous to the sending function.
Regards,
Leonardo Muzzi
|
|
|
|
|
It's most likely a leakage, I doubt you are really using all those handles. You may check for missing calls to Dispose() and similar.
Not only for sockets, since handles are used also for open files etc.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
thanks...'On top of that, you try to access the row before you actually add it to the rows collection'this helped me to solve the issue and also understand some basic concepts
|
|
|
|
|
Here's a useful snippet for you; rather than starting a new thread every time, you can reply to others on your existing thread. That way, it's all kept in one place (which incidentally should be in the VB.NET forum). Please stop creating new threads when one thread will do.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Private Sub addtopaymentbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addtopaymentbtn.Click
Dim i As Integer = DataGridView1.Rows.Count
DataGridView1.Rows(i-1).Cells("Details").Value=billcombo.SelectedItem
DataGridView1.Rows.Add()
End Sub
--------i changed my code like this.though it is not showing any error it is overwriting the previous results.Also i cant understand how the rows get added first and then the combobox value gets added,given i wrote code for adding rows in the end
|
|
|
|
|
It's a very similar problem to your last post. i-1 is the last element in the collection, so you need to change that to i . On top of that, you try to access the row before you actually add it to the rows collection.
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
My previous post doesn't means that!!!
Modify your code like
<br />
<br />
Private Sub addtopaymentbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addtopaymentbtn.Click<br />
<br />
DataGridView1.Rows(0).Cells("Details").Value = billcombo.SelectedItem<br />
Dim i As Integer = DataGridView1.Rows.Count<br />
DataGridView1.Rows.Add()<br />
DataGridView1.Rows(i).Cells("Details").Value=billcombo.SelectedItem<br />
End Sub<br />
<br />
|
|
|
|
|
Private Sub addtopaymentbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addtopaymentbtn.Click
DataGridView1.Rows(0).Cells("Details").Value = billcombo.SelectedItem
Dim i As Integer = DataGridView1.Rows.Count
i = i + 1
DataGridView1.Rows.Add()
DataGridView1.Rows(i).Cells("Details").Value=billcombo.SelectedItem
End Sub
_______i am selecting a value from a combobox(billcombo)and it is to be inserted into a datagrid for each addpaymentbtn click.But the code gives the below error
'Index was out of range. Must be non-negative and less than the size of the collection
Can anybody help me to sortout this problem
|
|
|
|
|
I see you are trying to access DataGridViewRow that doesn't exists.
Don't forget that DataGridViewRowCollection.Item is zero based index.
It means that row with number I has index I-1.Remove I=I+1 from your code!
|
|
|
|
|
Comment out the i = i + 1 line. This is because the Count property of a collection is almost always one higher than the number of items in that collection, because VB.Net starts counting at zero, instead of one
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hello,
I have an issue with EntityFramework and "set transaction isolation level read uncommitted"
We have changed EF to call a base class (by not using the edmx , this is possible)
In the base class we have overridden the createQuery method to include a call to a SSDL function
<Function Name="Uncommitted" IsComposable="false">
<CommandText>
set transaction isolation level read uncommitted
</CommandText>
</Function>
The reason we do this is so emulate (nolocks) on our sql and thereby help performance of our ASP Web Pages.
This however has brought up a problem.
we have an admin function that has a problem. (DeliveryMethods)
I have a attribute table which is keyed by deliveryMethod and attribute type.
Say I have RowA on that table.
I change and save a value on RowA using an enitiy object in the entityframework.
I then move off to another web page and copy RowA, again using an entity object in entityframework.
The problem is the copy of RowA contains the original values and not the changed ones.
If I do an IIS reset between the amendments and the copy then the new RowA has the changed values so it works ok.
looking at the SQL profiler - The update to the original RowA is
exec sp_executesql N'update [dbo].[DeliveryMethodsRuleAttributes]
set [IntAttribute] = @0, [LastUpdated] = @1, [LastUpdatedBy] = @2
where ([Id] = @3)
',N'@0 int,@1 datetime,@2 nvarchar(4),@3 uniqueidentifier',@0=40000,@1='2009-08-10 17:39:20:383',@2=N'mken',@3='2B60D845-411B-4337-A887-B6BB0F9B9309'
I changed @0 from 30000 to 40000.
The copy process does not issue an SQL Request , so there is no SQL read.
The Copy insert is.
exec sp_executesql N'insert [dbo].[DeliveryMethodsRuleAttributes]([Id], [DeliveryMethodRuleId], [DeliveryMethodId], [AttributeName], [DateTimeAttribute], [IntAttribute], [DecimalAttribute], [TextAttribute], [Created], [CreatedBy], [LastUpdated], [LastUpdatedBy])
values (@0, @1, @2, @3, null, @4, null, null, @5, @6, @7, @8)
',N'@0 uniqueidentifier,@1 uniqueidentifier,@2 uniqueidentifier,@3 nvarchar(14),@4 int,@5 datetime,@6 nvarchar(4),@7 datetime,@8 nvarchar(4)',@0='0264FECD-5EE4-49D3-9CE0-72BAAC11DAA6',@1='722456F0-ACE1-44B0-9568-A03CDD4453C5',@2='053C32B3-808C-4375-9826-02BDC55A8791',@3=N'PriceInCentsTo',@4=30000,@5='2009-08-10 17:42:03:780',@6=N'mken',@7='2009-08-10 17:42:03:780',@8=N'mken'
@4 is set to 30000, which was the original RowA value.
If I deactivate the "set transaction" then this problem does not happen.
Displosing and Closing the EF after the update of RowA has no effect.
Based on the SQL Profile, my theory is that the "uncommited" value is being held in the entityframework and/or underlying ado libraries and this cache is "feeding" the copy of RowA.
My Question is - How do I reset this cache after an update so that the next read uses the SQL DB?
Thanks
Martin
life is a bowl of cherries
go on take a byte
|
|
|
|
|
I am trying to calculate the expiry date for the local user accounts (on a workgroup) using Visual Studio 2008. I can read the last password change date from the "System.DirectoryServices.AccountManagement" namespace but I cannot find a way of reading the maximum password age. I have modified a method for reading this value from a domain (se below) but this returns 'Nothing':
Dim directoryEntry As New DirectoryEntry("WinNT://MyPCName")
strError = directoryEntry.Properties("maxPwdAge").Value
I'm starting to think I'm going about this the wrong way so any ideas would be greatly appreciated.
|
|
|
|
|
if no maximum password age was set by the administrators, I guess such code would return null, or throw an exception for a non-existing field.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks for the suggestion but I have already come across a situation like that one when trying to display the account lockout status. There is a maximum password age set (currently and 5 days for test purposes) and passwords do expire after the set number of days..
|
|
|
|
|
dim dr as oledbdatareader
dr = cmd.ExecuteReader()
dr = cmd1.ExecuteReader()
will the execution results be stored in dr.item(0) and dr.item(1) or will the second execution overwrites the first?i tried to add rows with dr.rows.add,but such a thing as addition of rows is not there..i tried executing and i gt the error msg 'Index was outside the bounds of the array'
If i want to execute it will i need to declare seperate data readers for that??
|
|
|
|
|
You definitely need two separate data readers!
EDIT: not sure what you are trying to do exactly, but be aware that data readers are read only.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
modified on Monday, August 10, 2009 1:55 PM
|
|
|
|
|
DataReader is readonly, forward only and for connected use. It means that at time you can access all fields for only one record. Then you need is to more forward and read the next and so until you are done with data. For example
OleDbReader dr = command.ExecuteReader();
while(dr.Read())
{
Cosole.WriteLine(dr[0].ToString());
Cosole.WriteLine(dr[1].ToString());
}
If you want to insert something then DataReader wouldn't help you. You need to write another command and execute it.
|
|
|
|
|
how to implement Filter for listbox using textbox in windows application using vb.net
i have a textbox and a listbox in my application
listbox id binded from database..
now when the user enters anything in textbox the items which starts with the text enterd in the listbox should filter and come in the first
(i mean list box is already filled in ascending order,so only the thing is the scroll should move to the starting of the word which is enterd in the textbox
)
how can i achieve this? any idea?..
(same like the index search in microsoft sites)
|
|
|
|
|
Hi,
I see basically three ways to achieve this:
1.
adapt the database query as you type, using a "LIKE '+myInitialText+"%'" clause. That would be easiest.
2.
adapt the items shown in some other way, maybe by copying them to a list, working on the list, and setting the new list as the new datasource
3.
leaving the items as is, however simply not showing some; that takes DrawMode.OwnerDrawVariable, and returning height zero in MeasureItem for the items you want to hide. (I haven't done this yet, but I think it should work).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
sorry for the noob question, but i really dont know how to parse down the question to get the answer.
what i am looking for is during setup of an installation program in VS2005 (or newer) how can i have a program added to a users right-click menu for specific file types. an example would be an ISO image burner that i have dl'd and when i right click on an ISO image, the program is present for me to choose.
so, how would i add that to my installation package?
many thanks in advance!
oed
|
|
|
|
|
oedipusrex wrote: how can i have a program added to a users right-click menu for specific file types.
I think you need to add your program in the context menu like the way if you right click on a text file "Notepad" application comes as an option.
You can try out the option mentioned here[^] (thoug i did not get a chance to veify ).
I found few products are also available [^]which you can add while packaging your installer and obviously it should permit your budget .
Keep me posted if you need any further help.
|
|
|
|
|
Thanks Arindam, I checked out that first link and I understand what he was talking about, however where in my installation package do I add that information? I get the whole merge module business but where or how does that get edited? I have checked the MSDN but either I do not know what to search for or how to phrase my question or simply not experienced enough (on a 4 level scale, I figure myself to be a level 2 programmer...I can code in c++ and vb and a little win32 and put together a simple install package, but that's it) and MSDN only gives a skeleton outline of the process of creating a merge module.
If I have to code it out directly, then that is fine. I am not asking for a direct step-by-step answer, only to be pointed in the right direction. Thanks a million!
|
|
|
|
|
oedipusrex wrote: package do I add that information?
I think probably you understand that you need to have something registry entry for your application (something like below one)
HKEY_CLASSES_ROOT\<file type>\shell\<display text>\command
Now your point is how to do that?
I think this MSDN article[^] might help you.
Keep me posted if this does not help you.
|
|
|
|
|