|
I'm shocked: the line
dataAdapter.Fill(dataSet, dataTableName);
(a local MySQL connection, ODBC, 8k rows)
took more than 1 min to execute, it needs about 2 min to show the window
just I'm so unlucky ? or it is a known performance problem here?
can I do something to speed it up? (I HAVE to show all those lines)
Thanks
|
|
|
|
|
I know the problem, mysql and odbc have a speed penalty in the managed code... try to use microsoft desktop database engine instead of the mysql database. This one is fully supported and costs nothing
Greetings....
|
|
|
|
|
Are there classes in C# to parse the HTML pages and do some related activities .
Srikar Y
NITK Surathkal
|
|
|
|
|
|
COM+ and remoting
Hi, I'm trying to expose COM+ component via remoting, it works just fine - it seems. But I'm confused by how COM+/Remoting works together.
Remoting - lifetime depends on whether the object is published as SAO(singleton/singlecall), CAO and lifetime services.
In COM+, lifetime of server objects (COM+ application/component) depends on object pooling and whether JIT is enabled. My understanding is that if a COM+ app is published via remoting, than activation option must be "server". I am a little confused at how/what determines an object's life time in this situation.
For instance, how can you have SAO/Singlecall and COM+ Object Pooling at the same time?
Following are nine possible scenario:
COM+ JIT enabled/Pooling disabled + CAO
COM+ JIT enabled/Pooling enabled + CAO
COM+ JIT disabled/Pooling disabled + CAO
COM+ JIT enabled/Pooling disabled + SAO/Singlecall
COM+ JIT enabled/Pooling enabled + SAO/Singlecall
COM+ JIT disabled/Pooling disabled + SAO/Singlecall
COM+ JIT enabled/Pooling disabled + SAO/Singleton
COM+ JIT enabled/Pooling enabled + SAO/Singleton
COM+ JIT disabled/Pooling disabled + SAO/Singleton
Any idea? Thanks!
norm
|
|
|
|
|
I tried launching a GUI app from Windows Service by first launching another console app (launch.exe), which in turn launch the GUI app.
I have tried using:
a. WinExec (both unmanaged Win32 console app and PInvoke in C# console app)
b. CreateProcess
c. System.Diagonostic.Start() method
in "launch.exe", none avoided "TypeInitializationException" (Exception triggered when you tried to launch anything with a GUI from a Windows Service.)
Is there anyway to get around this?
norm
|
|
|
|
|
Even if there is a way to get around this, I do not think that you should be doing this.
A windows service may be up and running before any user logs-in into the system. What do you propose would happen to such a UI in this case? This is precisely the reason why you cannot start a UI from the service. The context that windows uses for windows services is not the interactive user context, which is the requirement for UI.
Try changing the achitecture of your application.
|
|
|
|
|
Hi
I am trying to develop a toolbar (for IE)to bring up the annotations on the page on the browser . When a section of the text is highlited on the browser then i need to return the parent ID of he item selected .By ID i mean that assuming that each of the html atags in the page are given an ID tag such that we have a tree structure .
for eg
thus
the question is having sucha page i need to write a function to return the id of the parent node(since we have a tree structure ) of the portion of the text selected . Can any one guide me to do it(Using C#) . Is there any other way to do it .
And what are the classes to parse the html page currently in he rowser . is this the WebBrowser class . Please let me know about any classes that might be useful for the purpose . I shall look into the docs .
Srikar Y
NITK Surathkal
Srikar Y
NITK Surathkal
|
|
|
|
|
hi,
i have worker thread do a long running task. i start the thread at the app. startup.
i want to know any method to catch the exception throw inside the worker thread?
i can't see any entry point to catch the exception inside a worker thread.
any help?
regards,
jim
|
|
|
|
|
Have you tried Application.OnThreadException?
|
|
|
|
|
oh...
let me try !
thanks!
|
|
|
|
|
Hi,
I have some intensive code that is running on my main thread. I try to show a status update on a 'status form'. The problem that i have is that because it is running in the same thread the window is not responding to the user.
The user is now able to minimize, move the window because the code is too busy on it's own work.
(and they are all running on the same thread)
I thought the solution would be to run the window on a seperate thread. so I added the following code: 1 method called CreateStatusForm that creates the form and assigns it to my variable _frmStatus, and my code running this method in a seperate thread:
private void CreateStatusForm()
{
_frmStatus = new AdwareForm();
fInitializedStatus = true;
}
private AdwareTrace()
{
_oFormThread = new Thread(new ThreadStart(this.CreateStatusForm));
_oFormThread.Name = "Thread: StatusForm";
_oFormThread.Start();
while (oFormThread.IsAlive)
{
Thread.Sleep(250);
}
and so on ...
the problem is that on the initialization of the window runs on the seperate thread.
After the initialization the window does not respond to the user again.
Can anybody tell me how to run forms on seperate threads so that the users can continue to interact with it ?
Thanks very much in advance for your help,
Regards, SharpKnight
SharpKnight
|
|
|
|
|
Best solution is to use Thread Call back
like
threadcallback1 = new System.Threading.TimerCallback(fun1);
threadcallback2 = new System.Threading.TimerCallback(fun2);
So both are running at the differnt intereval you can make both of them run parallely.
hope this helps u
Regards
Sri
|
|
|
|
|
Trying to PInvoke CreateProcess, I looked up MSDN, it says library is "Kernel32.lib" - which is what I specified in my DllImport attribute. I keep getting the following exception:
"Unable To Load Dll"
I'm suspecting:
a. Shouldn't I be loading dll? Not lib? Anyway, another reference suggested to load "coredll.dll" (which is nowhere to be found on my XP)
b. return Type for CreateProcess is of type BOOL. In my C# code, I convert that to "int". Is this correct? Perhaps PInvoke failed because function signature doesn't match? I had same problem when I switched to BOOL. Also, does it matter if I use "class" (instead of struct) for "ProcessInfo"?
Here's what I did, can you see anything wrong here?
public Int32 GetPInvokeError()
{
return GetLastError();
}
//************ PInvoke ************ //
[StructLayout(LayoutKind.Sequential)]
public struct ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 dwProcessId;
public Int32 dwThreadId;
}
// Launch a process:
[DllImport("Kernel32.lib", SetLastError=true)]
private extern static int CreateProcess(
String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );
// GetLastError:
[DllImport("Kernel32.lib")]
private extern static Int32 GetLastError();
norm
|
|
|
|
|
I've also tried:
[StructLayout(LayoutKind.Sequential)]
public class ProcessInfo
{
public int hProcess;
public int hThread;
public int dwProcessId;
public int dwThreadId;
}
Which didn't help.
norm
|
|
|
|
|
norm wrote:
a. Shouldn't I be loading dll?
Yes.
BTW, there is already an implementation of CreateProcess in the .NET BCL - check out System.Diagnostics.Process .
|
|
|
|
|
Just got it, I ran into some docs, it should be "kernel32.dll", but that's not what it says on MSDN:
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.
So, next time when I see "XXXX.lib", I should just replace "lib" with "dll" then?
norm
|
|
|
|
|
I got it working now and is tackling on killing the process. I found this in C++/MFC - to translate to PInvoke, I need to identify corresponding dll for CWnd.
void CSomeDlg::killProcess()
{
HANDLE ps = OpenProcess( SYNCHRONIZE|PROCESS_TERMINATE, FALSE, processPid);
EnumWindows(EnumWindowsProc, processPid);
CloseHandle(ps) ;
}
BOOL CALLBACK CSomeDlg::EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
DWORD wndPid;
CString Title;
GetWindowThreadProcessId(hwnd, &wndPid);
CWnd::FromHandle( hwnd )->GetWindowText(Title); //ATTENTION: CWnd is MFC. I guess I need to find out in which dll CWnd resides...
if ( wndPid == (DWORD)lParam && Title.GetLength() != 0)
{
// Please kindly close this process
::PostMessage(hwnd, WM_CLOSE, 0, 0);
return false;
}
else
{
// Keep enumerating
return true;
}
}
Is there any easier alternative?
norm
|
|
|
|
|
Hmm... I'd advise that you use the BCL implementation.
Process process=Process.Start(filename);
ProcessStartInfo startinfo=new ProcessStartInfo();
Process process = Process.Start(startinfo);
process.CloseMainWindow();
|
|
|
|
|
What's BCL? Anyway, I got it. I just used C#/.NET framework, instead of WIN32 API OpenProcess then TerminateProcess. Here's the code:
try
{
System.Diagnostics.Process process = System.Diagnostics.Process.GetProcessById(nProcessID);
process.CloseMainWindow();
process.Close();
}
catch(Exception err)
{
throw new ApplicationException("Exception from CWin32ProcessUtil.KillProcess. ProcessID: " + nProcessID + " Info: " + err.Message);
}
I launched the process using WIN32 API coz I wanted to avoid "TypeInitializationException" when I tried to launch a GUI app from a Windows Service. Thanks though.
norm
|
|
|
|
|
norm wrote:
What's BCL?
Stands for Base Class Library.
-Nick Parker
|
|
|
|
|
I was hoping I could get away with "TypeInitializationException" via Win32 CreateProcess while launching a GUI app from OnStart (Windows Service)
I guess I was wrong.
norm
|
|
|
|
|
Hi ,
i have a winforms control that when i connect it to a datasource generates lots of different objects (all inheriting from component)
what i want is to add those components to the designer surface so that the controls can be accessed on the forms designer/propbrowser
so HOW do i make my control add the generated components to the designer host?
----
scenario:
i add the control to a form
i set a datasource to it
after the source is set , i want lots of dynamicly generated components to appear in the 'component pane' under the form.
//Roger
|
|
|
|
|
At run-time it is easy enough.
But I believe you want to do this at design-time?
If so, it sounds like you want to build a "plug-in." Kind of like the Add New Form wizards.
When you create a plug-in, it exposes the DTE object from which you can work with objects such as Solution, Project, etc.
Hopfully this provides a solution for your needs
|
|
|
|
|
i solved it..
i added a designer to my control and made the designer listen to events from the control
so when the control creates the dynamic components , the designer intercepts them and add them to the designer host..
//Roger
|
|
|
|