|
Sir Dave may it cause by copying one object from one for to another.. because i always do it.like copying toolstrip, menustrip, combo, etc.. is it right to do it that way? Should i need to create new object that in need in every new form i made?
|
|
|
|
|
What you're doing shouldn't corrupt the .resx file. But, then again, if you don't have the latest service pack installed, there's no telling. You might be forced to recreate the form from scratch. Do not copy the controls from the old form, but drag and drop new ones. You can copy and paste the code form the old form though.
|
|
|
|
|
I have a multi-threaded app where objects are enqueued by one thread and dequeued by the other (for sanity sake I'll call them the writer and reader threads).
The writer event is externally triggered and it is imperative that the trigger event is not delayed (which is why it is in its own thread).
There is an AutoResetEvent that is set to tell the reader thread that there are events to read. The problem is that if another writer event occurs while the reader is processing the queue it gives a System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
So - two questions:
(1) Is there a better architecture for this kind of situation
(2) If not, how do I prevent the error - i.e. how can the writer tell the reader to give is a rest for a while because more writing is going to be done?
(I could give code but it'd probably just confuse matters...)
|
|
|
|
|
Duncan Edwards Jones wrote: (1) Is there a better architecture for this kind of situation
Yes.
:: Use the Dequeue method instead of looping through the queue.
:: Lock the code that is queueing and the code that is dequeueing, so that they can't occur at the same time.
:: Only lock the code that is dequeueing the item, not the entire loop.
When you are using data in more than one thread, you have to use locking to prevent data corruption. The error message you are getting is because the collection has a built in protection that has detected that you have changed the collection in one thread while looping it in another.
---
single minded; short sighted; long gone;
|
|
|
|
|
I am populating an Grid for a db and one of the fields is a bit field called attachments. I would like to populate an attachment icon if the value is 1.
Thoughts......
|
|
|
|
|
Are you asking how to display an image in a DataGridView column instead of the value of the column??
Which version of VB.NET are you using?? Are you using a DataGrid or a DataGridView control??
|
|
|
|
|
when am deleting a control from panel am getting flickering i add suspendlayout and performlayout eventhough it is getting.How to avoid this
|
|
|
|
|
Which version of VB.NET are you using??
You might want to try turning on doublebuffering for the form the panel is on. What happens also depends on what you're doing with this panel. Why?? What's the thing for??
|
|
|
|
|
Hi everyone.
I´m doing an application with an MDI form, a button bar (toolstrip) and few child forms.
I made these forms of a specific size, and I want them to be that size, fixed borders, but when I opened them as MDI childs, they are enlarged, even though I set the maximum size in the size I want. If I set their size by code before opening then, the borders are resized, but the controls in it are kept as if it were larger.
One more thing, I tried 3 forms, the 3 are enlarged, but to different sizes.
Why is that, I just want my Forms the size I set them!!
Thank you!
|
|
|
|
|
Change you child forms FormBorderStyle property to FixedSingle.
|
|
|
|
|
I did that.
Anyway I found something, had to change AutoScaleMode property to None. It still changes the text size of some controls, but in can work on that.
Thank you
|
|
|
|
|
PabloGM wrote: I did that.
And?? It works fine for me. Everything stays the exact same size as when it was defined in the Designer.
|
|
|
|
|
The onlt way I can replicate what you're describing is to set the Size property of the form on creation, resetting what was done in the designer.
Quite literally, all i did to get it to work was create an MDIParent form and a child form. Set the child forms border style, have to code create about 10 cihld forms at runtime. Worked as expected. There was no change in the size of the forms and no way to resize them.
|
|
|
|
|
It didn't work for me just by setting te border style. I had to set the AutoScale to none.
But it's working fine now.
Thank you anyway.
|
|
|
|
|
VBA.
Ive a program wrote with a few sub's and functions, it all works fine but i need to call 1 of the subroutine's every x minutes
its more complicated than that tho...
If the user selects 15 mins, then the sub has to run once every 15 mins, but it has to run on minute 0, 15, 30, 45. If they select 30 mins the sub needs to run on 0 and 30, if they select 10 mins it has to run on 0, 10, 20, 30, 40 and 50, if they select any number of mins at all(from 1 to 60), the program has to work out when to run the sub and then run it at those times.
furthermore, If i select 10mins, it cant just start and run at like 3, 13, 23, 33, 43, it must run at 0, 10, 20, 30, 40, 50, note that it doesnt need to wait till 0 to begin, if the time is currently at 14 mins it can start at 20
|
|
|
|
|
this is on way (probably not the best but...)
put a timer on the form with as interval the smallest amount the user can give in (probably 1min)
in the timer_tick event put the following
'getting the current minute
dim d as double = date.now.minute
d = d/15 'userinput of minutes goes here
dim s as string = d
'check to see if s contains a ',' or '.' (depends on the regional settings I think)
if not s.contains(",") andalso not s.contains(".") then
'do whatever you want to happen
end if
why the check for ',' or '.' well if you do the calculation from the minutes / interval the result has to be an even number if its not then it's not time yet
example :
with 15
20/15=1,333333333...
30/15=2
40/15=2,666666...
with 6
35/6=5,833333....
12/6=2
46/67,66666...
you get the point right
hope it helps
ps: this is .net code so you might need to change it a bit
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
TDDragon wrote: dim d as double = date.now.minute
d = d/15 'userinput of minutes goes here
dim s as string = d
'check to see if s contains a ',' or '.' (depends on the regional settings I think)
if not s.contains(",") andalso not s.contains(".") then
'do whatever you want to happen
end if
What on earth is this garbage??
All you need to do is see if the number of minutes in the current time is a multiple of a given number! Why are you looking at strings and digging out punctuation?? It's simple math!
If currentTimeMinutes Mod selectedInterval = 0 Then
' launch function
End If
|
|
|
|
|
right sorry it's been a long day brain wasn't working to good anymore
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
There are two things required. A Timer control, set for about 1 minute (60000 milliseconds), and some very simple math. In the timer event, all you do is get the current time, look at the minutes property and see if it is a nice even multiple of the number of minutes your user has selected.
|
|
|
|
|
'mnPulse is a module level var
Static dtLastTick As Date = DateAdd(DateInterval.Minute, mnPulse * -1, Now)
If DateDiff(DateInterval.Minute, dtLastTick, Now) >= mnPulse Then
If Now.Minute Mod mnPulse = 0 Then
'Do your thing here
dtLastTick = Now
End If
End If
Hope this helps.
|
|
|
|
|
srone wrote:
'mnPulse is a module level var
Static dtLastTick As Date = DateAdd(DateInterval.Minute, mnPulse * -1, Now)
If DateDiff(DateInterval.Minute, dtLastTick, Now) >= mnPulse Then
If Now.Minute Mod mnPulse = 0 Then
'Do your thing here
dtLastTick = Now
End If
End If
What's with all the extra junk in bold?? You might want to re-read to OP's requirements. YOu're making it much harder than it needs to be.
|
|
|
|
|
You're correct, all he needs is
If Now.Minute Mod mnPulse = 0 Then
'Do your thing here
End If
with a timer.interval set to 60000.
If he wants the event to happen at 10:00 he will need all the rest with the interval set to 1000.
Not my first attempt at over engineering something.
|
|
|
|
|
consistently using bold for junk seems like a very good idea...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks for all your help and suggestions, the final code looks like this:
<code>
Sub PrintData()
Dim Interval As Integer
Dim n1 As Integer
Dim n2 As Integer
Interval = User_Log_Interval
n1 = Format(Now, "nn") 'Current Minute
n2 = Interval 'Interval
If (n1 Mod n2)= 0 Then
'Run Script
Else
'Dont Run Script
End If
End Sub</code>
|
|
|
|
|
after some more testing, "If (n1 Mod n2)= 0 Then" doesnt allow the current minute to be 00, and it doesnt allow the interval to be 0 or 1, i change it to the following code and all seems well "If Int(n1 / n2) = n1 / n2 Then"
|
|
|
|