|
Please describe what you mean by a 'roller', as it's not a term I'm familiar with, and I guess it isn't just a progress bar since you would already have found that.
|
|
|
|
|
A Roller is what I was told was that little animation that is played when a page loads and it takes a while to complete. Some of the cool flash or silverlight ones have a percentage.
|
|
|
|
|
Okay, that's what I thought you meant, but I wasn't sure.
According to this article[^], you can overwrite the template and put whatever you want in there, including a progress bar with a percentage (and a data binding). If you don't remove the default progress bar (as that article does), you can probably overlay it quite easily.
I haven't actually used this control though.
|
|
|
|
|
I'm making a website on job site.
Whenever I run the login form,I get an error:-
"An attempt to attach an auto-named database for file (C:\Users\ADMIN\Documents\Users.mdf) failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
Now I get an error"Invalid attempt to read when no data is present."
Help me!!!
modified 4-Oct-11 4:51am.
|
|
|
|
|
Are you sure that your mdf file have permissions?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
thnks!
The problem's solved!!!
|
|
|
|
|
Is that the mdf file doesn't have permissions?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
No, there was a small error in the code!
|
|
|
|
|
Ok,that's fine them. In most of the cases that error comes when you don't have permissions on it.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I'm using BeginReceive to receive data on a Socket.
Sometimes the receive completes synchronously, as indicated by the IAsyncResult.CompletedSynchronously member.
The problem is: I don't know how to retrieve the number of bytes received in this case, because usually it is the EndReceive function that returns this information. But you're not allowed to call EndReceive when it completes synchronously, because it will throw an InvalidOperation exception.
Does anyone know how to retrieve the number of bytes received when the receive completes synchronously?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
While I haven't read it in detail, I think this[^] not so simple thread holds the essentials.
|
|
|
|
|
Thanks, Luc. I read the thread, but there was no answer there.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I have never seen this, and there is nothing in the documentation that suggests it should be possible with an open socket. What exception message do you get? I suspect that the socket is already closed, and BeginReceive detects that and doesn't actually start the receive task. Some forms of socket closure don't get noticed until you try to do an operation on the socket, at which point it throws an exception, though it is usually a SocketException not an InvalidOperationException.
|
|
|
|
|
BobJanova wrote: I have never seen this, and there is nothing in the documentation that suggests it should be possible with an open socket.
Hi Bob,
Please have a look at the Exceptions table at this page: http://msdn.microsoft.com/en-us/library/w7wtt64b.aspx[^]
Look at the entry for EndReceive. It says it will throw InvalidOperation if EndReceive was already called. This is basically what happens when it completes synchronously.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Yes, but BeginReceive doesn't admit to being able to complete synchronously, and my sockets library works even though I wasn't aware it was possible (and therefore didn't code for it). I still think it's something to do with how you're using the socket.
|
|
|
|
|
I agree with the other response.
I have never seen it.
I have certainly seen some unusual errors caused by things like thread aborts and penetration testing though.
As a thought, as noted EndReceive will throw an exception if called twice, thus one reason for the exception is that it is being called twice, by your code.
|
|
|
|
|
Presumably you know this because you have gotten a CompletedSynchronously and you have gotten a InvalidOperation after that?
If so then there are two possibilities.
1. There is no data.
2. It is in the IAsyncResult somewhere.
|
|
|
|
|
1. Not true
2. Nowhere to be found.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
You are claiming that there is data even though you can't find it.
I suspect that you assume there is data - which is not the same thing.
|
|
|
|
|
Hey. Sorry if i have not quite got the lingo but here goes.
So i have declared an instance ('finalCellCompiler') of the CompileFinalCell class globally (for access across the whole form) and upon clicking the twoDDisplay button on the form finalCellCompiler is initialised with the *new keyword.
The CompileFinalCell class features the IDisposable wrapper and a dispose method to dispose of the object. A seperate reset button calls the clear method to get rid of the finalCellCompiler object.
The issue i have is that after calling the reset method and subsequently the twoDDisplay i get two instances of the finalCellCompiler as when i click a third button 'depositNext' (which is handled inside the CompileFinalCell class) the messageBox is call twice from each instance.
I am trying to figure out a way of replacing the original instance without creating major modifications to my code.
Any help would be greatly appreciated. Thanks.
public partial class Form1 : Form
{
private CompileFinalCell finalCellCompiler;
private void twoDDisplay_Click(object sender, EventArgs e)
{
finalCellCompiler = new CompileFinalCell(this,
fibrePositionGenerator, unitCellData.outerCellSize,
finalBeamForce, finalShellForce);
}
private void Clear()
{
if (finalCellCompiler != null)
{
finalCellCompiler.Dispose();
finalCellCompiler = null;
}
GC.Collect();
}
}
class CompileFinalCell : IDisposable
{
Form1 _form1Data;
public CompileFinalCell(Form1 originalFormData,
FibrePositionGenerator fibreData, SizeF outerCell,
ForceDirectedAlgorithm beamForce,
ForceDirectedAlgorithm shellForce)
{
_form1Data = originalFormData;
_form1Data.depositNext.Click += new
EventHandler(depositNext_Click);
}
private void depositNext_Click(object sender, EventArgs e)
{ MessageBox.Show("Button clicked"); }
public void Dispose()
{ GC.SuppressFinalize(this); }
}
|
|
|
|
|
The easiest way to achieve this would be to have a null check in your twoDDisplay_Click method to identify whether or not finalCellCompiler has previously been instantiated. If it has, don't do anything. BTW - it's generally not a good idea to force the garbage collector; let the runtime take care of that for you.
|
|
|
|
|
Hi, i know its not good practice to use the GC but i have been going round in circles trying to find a solution. I have checked finalCellCompiler when executing the twoDDisplay_click and it is equal to null before the new instance is created but i still appear to have two instances. And the more and more times i execute the reset button and then the twoDDisplay method i end up with more instances. I must be doing something fundamental wrong...?
|
|
|
|
|
Hi,
your CompileFinalCell objects never die; you may throw away the reference to them by setting finalCellCompiler = null; , however they are still reachable as they have attached themselves to your Form1 by executing
_form1Data.depositNext.Click += new EventHandler(depositNext_Click);
so as long as the Form is alive, so will all CompileFinalCell instances.
One way to resolve this is by having a counteraction inside the Dispose() method. Use -= as you did += .
I have some comments on your approach:
1.
it isn't quite all right to have an object modify its surroundings, as in _form1Data.depositNext.Click += new EventHandler(depositNext_Click); . One normally has the outer object to manage the inner ones, not the other way around. A room would know how many chairs are inside, the chairs wouldn't know about the room they are in. It is fundamentally wrong to pass Form1 into the CompileFinalCell class, your CompileFinalCell objects have a life of their own with or without some form. The right way would be to have events defined in CompileFinalCell, and the external world (the Form) to subscribe to those events, using delegates.
2.
From the code shown, I'm not convinced you need or want IDisposable, Dispose, and SuppressFinalize. But then, maybe you simplified the snippet.
3.
You trying to control the garbage collection is bad, as you know. When running in circles, keeping the things you know are bad is a sure way of not leaving said circles.
|
|
|
|
|
You are indeed correct, it was the event handler that was causing the problem. Thanks very much for this.
I am still learning so yeah there are some fundamental rules i am breaking. The reason for creating the event handlers inside the classes instead of the form1 was to keep things manageable (for me) as the application is quite large and there is a lot already going on in form1. I didn't see it to be too much of an issues but then again my program has a habit of crashing every no and then. I know its bad practice and when i get chance i will change it.
I dont think i actually need the dispose method for this particular class but for others it significantly reduced the amount of RAM i was using when using the profiler.
Is it bad to call the GC.Collect() method when performing intensive tasks or is that ok?
Thanks for the advice, it is much appreciated.
|
|
|
|
|
R4jlu wrote: Is it bad to call the GC.Collect() method
Yes, it is. The GC will collect when it needs more memory than is currently available (i.e. when you create another probably big object); there typically is no reason to free memory earlier than that (your app's memory most often isn't going to return to Windows anyway). So let it perform its job the way it thinks best.
You may start using GC judiciously after you have become an expert programmer...
|
|
|
|