Reinitializing cefsharp with new settings or adding a new cachepath - chromium-embedded

I have got CefSharp 3 with NuGet, and apparently it initializes as soon as the application starts debugging. My question is, how do I set the cachepath to Cef now that CefSharp 3 starts on its own and doesn't allow manual initialization.
Stopping it and trying to Initalize, isn't allowed neither.

Manual initialization is allowed and even encouraged. The automatic initialization is only a fallback as lots of new users struggled to get up and running quickly.
Simply call Cef.Initialize before you create the first ChromiumWebBrowser instance. This call needs to be made on the main application thread (typically the UI thread).
See a basic example at https://github.com/cefsharp/CefSharp.MinimalExample/blob/master/CefSharp.MinimalExample.WinForms/Program.cs#L15

Related

GWT Modlue Restarts cause Out of Memory Error

I'm developing a GWT application, and I'm having issues with testing in development mode in eclipse.
When I make changes to the client-side code, I refresh the browser page (F5) to reload the module. Every time I do this (whether the code has changed or not), the Development Tab in eclipse shows a new bullet point with "Module xxxx has loaded". As well, according to Task Manager, every time I do this, the javaw.exe host process increases by about 1MB of memory. Eventually (10-20 refreshes later), the page fails to load and the Development Mode tab shows this error:
Out of memory; to increase the amount of memory, use the -Xmx flag at startup (java -Xmx128M ...)
I can fix this by stopping and restarting the server (not the little refresh button in the Developer Mode tab, but the red stop button), but it then the module has to be revalidated, which takes a while. It seems that eclipse doesn't realize I've finished with the old module when I reload a new one. I'm observing the same behavior with a brand-new GWT project, so I don't think it's my code. Is anyone aware of a way to remedy this?
EDIT: See both answers below for possible solutions.
The default settings gwt dev mode use are the minimum , so you hit an out of memory really quickly.
From this you can see that the permgenspace is to low and if you refresh 20 times in a short periode it will go out of memory.
you can start by using following vmargs :
-Xms512m -Xmx512m -XX:MaxPermSize=256M -XX:+UseParallelGC
But as enrybo pointed out if your application grows it requires more memory:
-Xms512m -Xmx1g -XX:MaxPermSize=256M -XX:+UseParallelGC
There isn't really all that much you can do. As you mentioned you can increase the memory but eventually you'll run into the same problem even with more allocated memory.
I suggest you try to run in Super Dev Mode but in that case you'll need to update the SDK you're using to 2.5.1+. With Super Dev Mode your browser does not need a plugin because it will actually be running true Javascript. You even have the ability to debug in your browser but looking at your Java source (using source maps).

WPF application calls an API that needs a message pump; Dispather.Run() causes problems

I have a WPF app that uses a non-WPF vendor library. My app does not receive any events that the library fires. I've been told that this is because I need a message pump.
In another (very similar) question, the accepted answer suggested using System.Windows.Threading.Dispatcher.Run().
When I add in that call, however, my window won't pop up-- the app is effectively backgrounded and I have to shut it down with Task Manager.
I'm really stumped here, and I'm not even sure how to investigate it. Any help would be greatly appreciated.
You already have one if you use WPF, there's no other way that it can get any Windows notifications. Every WPF app starts life with a call to Application.Run() on the main thread. It is usually well hidden, auto-generated in the bin\debug\app.g.cs source code file. Application.Run() in turn calls Dispatcher.Run()
Your vendor is correct, without a message loop many COM components go catatonic. But since you have one you need to look for the problem elsewhere. Don't use the component on threads.

Is it possible for an application to take ownership of a window from another application?

Basically, I have two applications that run sequentially (second is started by the first, and the first exits immediately after.) I'd like to pass ownership of a window the first application created to the second application. The actual contents of the window don't need to be passed along, it's just being drawn in by DirectX.
Alternatively, but less desirably, is it possible to at least disable the window closing/opening animation, so it at least looks like the desired effect is achieved?
(This is in C, using the vanilla Win32 API.)
Instead of separated application make a DLL that will be loaded by the first application and run within it.
I suspect that you're going to run into problems because the WindowProc function is located in the memory address space of the program that you're closing.
Also, a quick look at the second remark at the bottom of the documentation for RegisterClass doesn't seem to offer up much hope.
The only work around that I can suggest for what you've described is to not close the first application until the second application is finished with the window in question.
you can use API hooking to make your DLL capture API windows calls sent by the application window and respond as if your DLL is the windows DLL
for more information about hooking check :
Hooks Overview

19 Threads for WPF Application

I just created a new WPF application which has about 5 windows and makes use of the Xceed Data Grid. After looking in the task manager I saw that this small application had 19 threads running.
Can this be correct? I expected the WPF framework to use 2-3 threads, but not 19.
Or am I doing anything wrong?
First, it isn't 19.
When running a "Hello, World!" WPF app, I see 10 threads in Task Manager. When running the same app using the Visual Studio debugger, it uses 19. So, first, factor out 9 of these added as overhead from the debugger.
Now for the 10.
According to a MSDN Magazine article called "Build More Responsive Apps With The Dispatcher", WPF starts out with two threads:
All WPF applications start out with
two important threads, one for rendering and one for managing the user interface. The rendering thread
is a hidden thread that runs in the
background, so the only thread that
you ordinarily deal with is the UI
thread.
But according to this article, there are lots of basic threads in all managed apps, WPF or not:
There are different types of .NET
threads: finalizer, GC, debugger,
timer, threadpool, primary and
background threads. But not all
threads related to .NET are managed.
Starting with the two from WPF, add in the GC and the finalizer to get up to four. Add in the debugger thread (all managed apps have one even when not debugging) to get to five. Add the timer to get to six.
And, attaching a debugger to my WPF app after starting it outside VS, I can see there are two worker threads in the thread pool. This is likely a minimum. This gets my app up to eight.
There are two I cannot account for exactly, but they are likely COM threads for interop (they are definitely not managed threads). The second article I referenced discusses more of these.
But the real moral of the story here is, don't worry about them. If a vanilla "Hello, World!" app uses 10, that is your baseline. Only worry about threads you create beyond this minimum.

WPF application freeze

I am kind of lost here, and I don't know what to do
I have a problem that I don't know what the source of it.
We have a large wpf application, that is built similar to prism (composite application)
Actually we are using lots of prism library.
I wrote a module to replace an existing module.
And the application now is loading my module, instead of the old module.
I start to notice, with the new module, that sometimes the application freeze for 20-30 seconds without any response, and then it work smoothly after that.
The freeze is not consistent, and there is no pattern or a specific reason that cause it.
I am suspecting that could be my module that is causing that freeze.
But at the same time, many other developers introduced new code to the application.
My question is there a way to trace that freeze?
Is there a way to compare the old module and the new module that I wrote?
I can run the application with my module, and trace the application, and then I can change the config file to load the old module.
Is there a way to compare between the two?
Should I do profiling?
and if profiling will help, then what should I look for?
any other tool could help?
Thanks a lot for any reply
It sounds like you are doing a long running operation on your UI thread. Are you making any database / webservice calls from the main thread? I think one of the easiest things to do is run it in the debugger, and when it freezes, hit the "pause" button. Visual Studio will pause execution at the current location, and you can examine what is taking so long.
If the problem isn't immediately obvious there, I would definitely start profiling the application to track this down.

Resources