I have an interesting problem (Interesting to me, anyway ). I have a form loading, and in the process, an RTB is being loaded with a really super long RTF string. In the process, I get the ContextSwitchDeadlock message box. Now, from what I can gather, it seems to be telling me that system requests have not been able to be carried out for at least 60 seconds while the string is being loaded, and the message is telling me that you can't expect to be able to do anything else while that is going on, AND there may be an evergrowing queue of system tasks that have been put off until the string finishes loading. If this is true, I imagine I am getting the message because this is not a case where DoEvents() would be of any help...As the RTB is being loaded with the string, all of that activity is not code that a DoEvents() line can be inserted into.
So I started looking around, and discovered talk about message pumps (message loops), but no great information on them in general. So my question is, is a message pump what I need, and if so, how do I implement such a thing?
Your app already has a message pump. It always runs on the UI thread (startup thread) and it's the little bugger that triggers that message "Not responding" when your code blocks the UI thread and the message pump can't be processed because of it.
The message you're getting is because COM interop happens through the message pump. You app is using a COM-based component (whether you know it or not) and COM message are not being processed because the message pump is prevented from running by your extremely long running operating (the RTF load).
Adding a second message pump isn't going to accompish anything because it also will be blocked.
The good news is that message only appears when running the code under the debugger. Even better, you can disable it in your app.config. See this[^].
THe better solution would be to NOT load such a massive document into the RTB.
I was trying add current date to a textbox in the current control when a user press something like Alt+D. I used an example from this Article: Setting A Global Hot Key I modified the code to something like this:
ProtectedOverridesSub WndProc(ByRef msg As System.Windows.Forms.Message)
'We only care about hotkey messagesCase ForcHotKey.WM_HOTKEY
'if this is our hotkey and the ActiveControl from the ActiveForm is a textbox, Insert the current date.IfCShort(msg.WParam) = m_HotkeyID ThenIfTypeOf (Me.ActiveForm.ActiveControl) Is TextBox ThenMe.ActiveForm.ActiveControl.Text = Me.ActiveForm.ActiveControl.Text.Insert(Me.ActiveForm.ActiveControl.Text.Length, DateTime.Now.ToShortDateString)
'move the cursor to endDim tb As TextBox
tb = Me.ActiveForm.ActiveControl
EndIfEndIfExitSelectCaseElse'pass it back to main WndProcMyBase.WndProc(msg)
All I have to do is to register the hotkey in the main MDI Form. No matter which form I'm at, while typing in the textbox whenever I press hotkey I get the current date.
Just created a vb-project, thrown in a second blanc Form and called it from a button's click using the ugly "Form2.Show"-approach. Using ILSpy, it's visible what's being generated;
public Form1 m_Form1;
public Form2 m_Form2;
// ..more..public Form2 Form2
this.m_Form2 = MyProject.MyForms.Create__Instance__<Form2>(this.m_Form2);
bool flag = value == this.m_Form2;
flag = (value != null);
thrownew ArgumentException("Property can only be set to Nothing");
It's sealed, and generated by the compiler. It's only "illegal" if you change the project type from "Windows Forms Application" to "Console Application". Alternatively, one could consider the factory-pattern for forms;
<Obsolete("Use the CreateNew method")>
EndSubPrivateSubNew(ByVal skip AsBoolean)
' This call is required by the designer.
EndSubPublicSharedFunction CreateNew() As Form2
ReturnNew Form2(True) ' use generics for a real factory :)EndFunctionEndClass
The generated code will try to use the parameterless version of the constructor, and throw an ApplicationException. Not a very good alternative.
I think this would be better solved by writing an FxCop-rule.
Bastard Programmer from Hell If you can't read my code, try converting it here[^]
I think you are describing the default instances of the project's forms that are created when the "application framework" is enabled (if this is not the case, please ignore the rest of this). Enabled is the default case when using the "Windows Forms Application" template to create a new project.
To avoid these default instances, create your project using the "Empty Project" template. When starting with "Empty Project", you will not initially have the "My" namespace available, but it will be created for you if you go to Project Properties->Settings and click on "This project does not have a default settings file. Click here to create one.". This will reclaim My.Settings for you but nothing else, but most of that stuff is just icing anyways. If you feel the need, you could always add them back into the "My" namespace.
I have created a setup of my project and in the custom actions I am running two .EXE file. One for key generation and the other for deleting the Key generation executable. The problem which happens because of the deletion of this key generation file is that the shortcut created then tries to reload the setup since there has been change in the startup folder. I have tried to make the two executable VITAL = "FALSE". Still it does not work.
I am using VB 2008 Setup and Deployment option
Need help in solving either of the two issues:
1. Is there any way I can run an executable without getting it copied into the startup folder? 2. If no, then how to make the shortcut refer to the main executable file even after the file is deleted from the startup folder?
I am facing a very typical problem. Let me try to define the issue
I have a label which has a text value as $789.75. When I transfer this value to a String variable the value becomes $789.75. Now if I have VB 2008 installed in the machine and when I run the program I can transfer this label text into a Double variable and after transfer the value of the DOUBLE variable becomes 789.75. How This happens I am not aware. This works even if I have installed VB some time and have now un-installed it. But if I make a setup file and install in a machine which does not have VB installed then it gives error "Not able to convert String to Double".
I hope I am able to clearly state my problem.
Can anybody tell me which .NET or .COM file is helping in this conversion from string to double without the $ sign. This will help me in adding that file when I am creating the setup.
Richard, Thanks for the suggestion. What i am using is CType method. As far as Double.Tryparse method is concerned, I find according to MSDN it does not work on strings which contain $ sign. Double.Tryparse can take care of <,> and exponents. My issue is as told before, if VB .net is installed in the machine then CTYPE(string, Double) returns only the number 757.49 where string = $757.49. But when VB .net is not installed same command throws an error "Cannot convert String to Double".
According to the documentation[^] this is compiled inline so it should work on any system, as long as you have the correct version of .NET installed. Sorry, but I cannot suggest anything more that would help.
Thanks Richard. I really appreciate taking some time out and trying to solve my problems. I am also not sure why this is working in one machine and not in another. As far as .Net is concerned I have .net Framework 4 installed in both the machines. I will try out some more combinations.
Have you compared the regional settings of the various machines? At a guess I would say that the development environment is using English(United States) or some other culture that has $ for the currency symbol. All the 'helpful' stuff built into the VB conversion routines is probably ignoring the default currency symbol.