text stringlengths 0 30.5k | title stringclasses 1
value | embeddings listlengths 768 768 |
|---|---|---|
I'd like to ask a question then follow it up with my own answer, but also see what answers other people have.
We have two large files which we'd like to read from two separate threads concurrently. One thread will sequentially read fileA while the other thread will sequentially read fileB. There is no locking or communication between the threads, both are sequentially reading as fast as they can, and both are immediately discarding the data they read.
Our experience with this setup on Windows is very poor. The combined throughput of the two threads is in the order of 2-3 MiB/sec. | [
0.25625136494636536,
-0.19459325075149536,
-0.02564423345029354,
0.06652605533599854,
0.2791914641857147,
-0.13935385644435883,
0.012616081163287163,
0.02880425751209259,
-0.19484463334083557,
-0.7084899544715881,
0.06717250496149063,
0.48352140188217163,
-0.1448088437318802,
0.31738364696... | |
The drive seems to be spending most of its time seeking backwards and forwards between the two files, presumably reading very little after each seek.
If we disable one of the threads and temporarily look at the performance of a single thread then we get much better bandwidth (~45 MiB/sec for this machine). So clearly the bad two-thread performance is an artefact of the OS disk scheduler.
**Is there anything we can do to improve the concurrent thread read performance?** Perhaps by using different APIs or by tweaking the OS disk scheduler parameters in some way.
Some details:
The files are in the order | [
0.42568832635879517,
0.0300300195813179,
0.47069641947746277,
0.23009486496448517,
-0.026710117235779762,
-0.0455373078584671,
0.2763362228870392,
0.06321785598993301,
-0.07862447202205658,
-0.6667509078979492,
0.10366244614124298,
0.8411797285079956,
-0.2869707942008972,
0.302351951599121... | |
of 2 GiB each on a machine with 2GiB of RAM. For the purpose of this question we consider them not to be cached and perfectly defragmented. We have used defrag tools and rebooted to ensure this is the case.
We are using no special APIs to read these files. The behaviour is repeatable across various bog-standard APIs such as Win32's CreateFile, C's fopen, C++'s std::ifstream, Java's FileInputStream, etc.
Each thread spins in a loop making calls to the read function. We have varied the number of bytes requested from the API each iteration from values between 1KiB up to 128MiB. Varying | [
0.2815071940422058,
-0.010940411128103733,
0.22522638738155365,
0.04681774601340294,
-0.04207097738981247,
0.056524697691202164,
0.3031655550003052,
-0.26610562205314636,
-0.16192708909511566,
-0.6340600848197937,
0.034373242408037186,
0.3484433591365814,
-0.34515005350112915,
0.0984364822... | |
this has had no effect, so clearly the amount the OS is physically reading after each disk seek is not dictated by this number. This is exactly what should be expected.
The dramatic difference between one-thread and two-thread performance is repeatable across Windows 2000, Windows XP (32-bit and 64-bit), Windows Server 2003, and also with and without hardware RAID5.
The problem seems to be in Windows I/O scheduling policy. According to what I found [here](http://engr.smu.edu/~kocan/7343/fall05/slides/chapter11.ppt "I/O management and disk scheduling") there are many ways for an O.S. to schedule disk requests. While Linux and others can choose between different policies, before Vista | [
-0.1421983242034912,
-0.052321672439575195,
0.29872068762779236,
0.10914409160614014,
0.0888865664601326,
-0.19460424780845642,
0.026645097881555557,
0.2562870979309082,
-0.5982908010482788,
-0.7617674469947815,
-0.05179750546813011,
0.7154088616371155,
-0.08358454704284668,
0.093418456614... | |
Windows was locked in a single policy: a FIFO queue, where all requests where splitted in 64 KB blocks. I believe that this policy is the cause for the problem you are experiencing: the scheduler will mix requests from the two threads, causing continuous seek between different areas of the disk.
Now, the good news is that according to [here](http://technet.microsoft.com/en-us/magazine/cc162494.aspx "Inside Windows Vista Kernel") and [here](http://widefox.pbwiki.com/IO "Kernel Comparison: Linux (2.6.22) versus Windows (Vista)"), Vista introduced a smarter disk scheduler, where you can set the priority of your requests and also allocate a minimum badwidth for your process.
The | [
0.1769128441810608,
-0.26638883352279663,
0.49132591485977173,
0.10980916023254395,
-0.013263864442706108,
-0.11870160698890686,
0.11251294612884521,
0.08158224821090698,
-0.49608883261680603,
-0.5060022473335266,
-0.097327820956707,
0.6619104146957397,
-0.4175715744495392,
0.0985300838947... | |
bad news is that I found no way to change disk policy or buffers size in previous versions of Windows. Also, even if raising disk I/O priority of your process will boost the performance against the other processes, you still have the problems of your threads competing against each other.
What I can suggest is to modify your software by introducing a self-made disk access policy.
For example, you could use a policy like this in your thread B (similar for Thread A):
```
if THREAD A is reading from disk then wait for THREAD A to stop reading | [
0.2670453190803528,
0.15489870309829712,
0.08471579104661942,
0.05360882729291916,
-0.10673534870147705,
-0.210654154419899,
0.16116546094417572,
0.3923693895339966,
-0.43065178394317627,
-0.6338808536529541,
0.07585647702217102,
0.6120932698249817,
-0.28345826268196106,
0.4639462530612945... | |
or wait for X ms
Read for X ms (or Y MB)
Stop reading and check status of thread A again
```
You could use semaphores for status checking or you could use perfmon counters to get the status of the actual disk queue.
The values of X and/or Y could also be auto-tuned by checking the actual trasfer rates and slowly modify them, thus maximizing the throughtput when the application runs on different machines and/or O.S. You could find that cache, memory or RAID levels affect them in a way or the other, but with auto-tuning you will always get the best | [
0.5277015566825867,
-0.3068021237850189,
0.509136438369751,
0.3369421064853668,
-0.1068863570690155,
0.18084995448589325,
0.2715272009372711,
0.09803678095340729,
-0.39015987515449524,
-0.4978314936161041,
0.13696984946727753,
0.7935508489608765,
-0.19878506660461426,
0.1896084100008011,
... | |
performance in every scenario. | [
-0.1726655215024948,
0.04737717658281326,
-0.11798783391714096,
0.37915652990341187,
-0.05451401323080063,
0.19196400046348572,
0.30044782161712646,
-0.1614813357591629,
-0.2947642505168915,
-0.7434912919998169,
0.034105975180864334,
0.4035835862159729,
-0.011877384036779404,
-0.2243786156... | |
*Note: This was posted when I was starting out C#. With 2014 knowledge, I can truly say that auto-properties are among the best things that ever happened to the C# language.*
I am used to create my properties in C# using a private and a public field:
```
private string title;
public string Title
{
get { return title; }
set { title = value; }
}
```
Now, with [.NET](http://en.wikipedia.org/wiki/.NET_Framework) 3.0, we got auto-properties:
```
public string Title { get; set; }
```
I know this is more a philosophical/subjective questions, but is there any reason to use these auto-properties except from saving | [
0.4715030789375305,
0.3402025103569031,
0.22028720378875732,
0.044691264629364014,
0.007373933680355549,
-0.21471934020519257,
0.22893549501895905,
-0.09543751180171967,
-0.12269264459609985,
-0.5397831797599792,
-0.17979104816913605,
1.1087795495986938,
-0.03134646266698837,
0.01537415478... | |
five lines of code for each field? My personal gripe is that those properties are hiding stuff from me, and I am not a big fan of black magic.
In fact, the hidden private field does not even show up in the debugger, which is OK given the fact that the get/set functions do nothing. But when I want to actually implement some getter/setter logic, I have to use the private/public pair anyway.
I see the benefit that I save a lot of code (one vs six lines) without losing the ability to change the getter/setter logic later, but then again I | [
0.3965877294540405,
-0.03632332384586334,
0.07144904881715775,
0.237235888838768,
-0.13751134276390076,
-0.009257127530872822,
0.5065884590148926,
-0.15754742920398712,
-0.07552523165941238,
-0.35249412059783936,
0.03818143531680107,
0.4224868714809418,
-0.06308181583881378,
-0.03382734581... | |
can already do that by simply declaring a public field "Public string Title" without the need of the { get; set; } block, thus even saving more code.
So, what am I missing here? Why would anyone actually want to use auto-properties?
We use them all the time in Stack Overflow.
You may also be interested in a discussion of [Properties vs. Public Variables](http://blog.codinghorror.com/properties-vs-public-variables/). IMHO that's really what this is a reaction to, and for that purpose, it's great. | [
0.6189800500869751,
-0.21086600422859192,
-0.23896154761314392,
0.16789492964744568,
-0.06337953358888626,
-0.7638478875160217,
0.22364692389965057,
-0.08522181212902069,
-0.3741181790828705,
-0.3085125982761383,
-0.005958226975053549,
0.7186628580093384,
-0.11991383135318756,
0.2671858668... | |
How do you create a static class in C++? I should be able to do something like:
```
cout << "bit 5 is " << BitParser::getBitAt(buffer, 5) << endl;
```
Assuming I created the `BitParser` class. What would the `BitParser` class definition look like?
If you're looking for a way of applying the "static" keyword to a class, like you can in C# for example, then you won't be able to without using Managed C++.
But the looks of your sample, you just need to create a public static method on your BitParser object. Like so:
**BitParser.h**
```
class BitParser
{
public:
static bool getBitAt(int buffer, int bitIndex); | [
0.10720301419496536,
-0.07852025330066681,
0.14466537535190582,
-0.05411396920681,
-0.1831345409154892,
-0.106705442070961,
0.23054738342761993,
-0.14200210571289062,
-0.006978648714721203,
-0.2843509614467621,
-0.18077918887138367,
0.468317449092865,
-0.6072525382041931,
0.111654706299304... | |
// ...lots of great stuff
private:
// Disallow creating an instance of this object
BitParser() {}
};
```
**BitParser.cpp**
```
bool BitParser::getBitAt(int buffer, int bitIndex)
{
bool isBitSet = false;
// .. determine if bit is set
return isBitSet;
}
```
You can use this code to call the method in the same way as your example code. | [
0.17598764598369598,
0.04114560782909393,
0.22057850658893585,
0.06013667583465576,
-0.013499578461050987,
-0.25365903973579407,
0.4077685475349426,
-0.21103349328041077,
-0.20166410505771637,
-0.44877439737319946,
-0.06588301807641983,
0.38159066438674927,
-0.39511576294898987,
0.17124034... | |
Do you use ILMerge? Do you use ILMerge to merge multiple assemblies to ease deployment of dll's? Have you found problems with deployment/versioning in production after ILMerging assemblies together?
I'm looking for some advice in regards to using ILMerge to reduce deployment friction, if that is even possible.
I use ILMerge for almost all of my different applications. I have it integrated right into the release build process so what I end up with is one exe per application with no extra dll's.
You can't ILMerge any C++ assemblies that have native code.
You also can't ILMerge any assemblies that contain XAML for | [
0.496412068605423,
0.1956726610660553,
0.09767859429121017,
-0.15983644127845764,
-0.32618510723114014,
-0.2676938474178314,
0.22328321635723114,
-0.35572096705436707,
-0.31404295563697815,
-0.6764118671417236,
-0.08033794164657593,
0.6884863972663879,
-0.9031467437744141,
0.04634098708629... | |
WPF (at least I haven't had any success with that). It complains at runtime that the resources cannot be located.
I did write a wrapper executable for ILMerge where I pass in the startup exe name for the project I want to merge, and an output exe name, and then it reflects the dependent assemblies and calls ILMerge with the appropriate command line parameters. It is much easier now when I add new assemblies to the project, I don't have to remember to update the build script. | [
0.3319523334503174,
-0.008681641891598701,
0.3903454542160034,
-0.4214709401130676,
-0.12374962866306305,
-0.155610129237175,
0.17107312381267548,
-0.4193412959575653,
-0.17352481186389923,
-0.5663909912109375,
0.15595275163650513,
0.6830929517745972,
-0.24897001683712006,
-0.1690057516098... | |
I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C?
**Declaration**
A prototype for a function which takes a function parameter looks like the following:
```
void func ( void (*f)(int) );
```
This states that the parameter `f` will be a pointer to a function which has a `void` return type and which takes a single `int` parameter. The following function (`print`) is an example of a function which could be passed to `func` as a parameter because it is the proper type:
```
void print ( int | [
0.25811612606048584,
0.21960708498954773,
0.0693453699350357,
-0.09120838344097137,
-0.2228216975927353,
-0.08357243984937668,
-0.07974403351545334,
-0.10012402385473251,
0.030855685472488403,
-0.4596157670021057,
0.04319218918681145,
0.4649037718772888,
-0.4600801169872284,
0.196115538477... | |
x ) {
printf("%d\n", x);
}
```
**Function Call**
When calling a function with a function parameter, the value passed must be a pointer to a function. Use the function's name (without parentheses) for this:
```
func(print);
```
would call `func`, passing the print function to it.
**Function Body**
As with any parameter, `func` can now use the parameter's name in the function body to access the value of the parameter. Let's say that `func` will apply the function it is passed to the numbers 0-4. Consider, first, what the loop would look like to call print directly:
```
for ( int ctr = 0 ; ctr < 5 ; ctr++ | [
0.024425731971859932,
0.17227204144001007,
0.4620150625705719,
-0.2606380581855774,
-0.14057299494743347,
0.06435581296682358,
-0.08439293503761292,
-0.2575487494468689,
0.01658155396580696,
-0.27395209670066833,
-0.397073894739151,
0.7449228167533875,
-0.5050484538078308,
0.04616904631257... | |
) {
print(ctr);
}
```
Since `func`'s parameter declaration says that `f` is the name for a pointer to the desired function, we recall first that if `f` is a pointer then `*f` is the thing that `f` points to (i.e. the function `print` in this case). As a result, just replace every occurrence of print in the loop above with `*f`:
```
void func ( void (*f)(int) ) {
for ( int ctr = 0 ; ctr < 5 ; ctr++ ) {
(*f)(ctr);
}
}
```
[Source](http://math.hws.edu/bridgeman/courses/331/f05/handouts/c-c++-notes.html) | [
-0.07813394069671631,
0.22483976185321808,
0.5978208780288696,
-0.3237248957157135,
0.07728800922632217,
-0.030879661440849304,
-0.022349391132593155,
-0.2054353505373001,
-0.21241730451583862,
-0.2007579356431961,
-0.6117694973945618,
0.7067608833312988,
-0.39298999309539795,
0.0522885173... | |
In my ASP.NET User Control I'm adding some JavaScript to the `window.onload` event:
```
if (!Page.ClientScript.IsStartupScriptRegistered(this.GetType(), onloadScriptName))
Page.ClientScript.RegisterStartupScript(this.GetType(), onloadScriptName,
"window.onload = function() {myFunction();};", true);
```
My problem is, if there is already something in the `onload` event, than this overwrites it. How would I go about allowing two user controls to each execute JavaScript in the `onload` event?
**Edit:** Thanks for the info on third party libraries. I'll keep them in mind.
Most of the "solutions" suggested are Microsoft-specific, or require bloated libraries. Here's one good way. This works | [
0.09194574505090714,
-0.00027384853456169367,
0.38124731183052063,
-0.0071191261522471905,
-0.04746587947010994,
-0.15618599951267242,
0.3786277770996094,
-0.2088051289319992,
-0.2606258988380432,
-0.9393259882926941,
-0.1583130657672882,
0.5944755673408508,
-0.29439687728881836,
-0.138582... | |
with W3C-compliant browsers and with Microsoft IE.
```
if (window.addEventListener) // W3C standard
{
window.addEventListener('load', myFunction, false); // NB **not** 'onload'
}
else if (window.attachEvent) // Microsoft
{
window.attachEvent('onload', myFunction);
}
``` | [
-0.02280178666114807,
0.14009343087673187,
0.3333469331264496,
-0.07686226814985275,
0.05222959443926811,
-0.25469446182250977,
0.43368688225746155,
-0.024298960343003273,
0.10010886937379837,
-0.8428226709365845,
-0.39614397287368774,
0.7177589535713196,
-0.35367831587791443,
0.1009970605... | |
I have a WCF service that I have to reference from a .net 2.0 project.
I have tried to reference it using the "**add web reference**" method but it messes up the params.
For example, I have a method in the service that expects a `char[]` to be passed in, but when I add the web reference, the method expects an `int[]`.
So then I tried to setup **svcutil** and it worked... kind of.
I could only get the service class to compile by adding a bunch of *.net 3.0* references to my *.net 2.0* project. This didn't sit well with | [
0.48327332735061646,
0.14624924957752228,
0.41834720969200134,
-0.21875649690628052,
-0.4068049490451813,
-0.2009509652853012,
0.3832508623600006,
-0.3567698001861572,
-0.05314667895436287,
-0.6184657216072083,
0.2763877511024475,
0.5318430662155151,
-0.5196541547775269,
0.3735313713550567... | |
the architect so I've had to can it (and probably for the best too).
So I was wondering if anyone has any pointers or resources on how I can setup a *.net 2.0* project to reference a **WCF service**.
One of those instances that you need to edit the WSDL. For a start a useful tool
<http://codeplex.com/storm> | [
0.6799035668373108,
-0.0838233008980751,
0.05704152584075928,
-0.015039380639791489,
-0.15239669382572174,
-0.14116188883781433,
0.3652430474758148,
0.1077858954668045,
-0.4688322842121124,
-0.5783645510673523,
0.1968715786933899,
0.42817381024360657,
0.06286681443452835,
0.124388292431831... | |
I could swear I've seen people typing function headers and then hitting some key combination to auto-create function braces and insert the cursor between them like so:
```
void foo()_
```
to
```
void foo()
{
_
}
```
Is this a built-in feature?
Check out [Resharper](http://www.jetbrains.com/resharper/documentation/feature_map.html) - it is a Visual Studio add-on with this feature, among many other development helps.
Also see [C# Completer](http://www.knowdotnet.com/articles/csharpcompleter.html), another add-on.
If you want to roll your own, check out [this article](http://www.developer.com/net/cplus/article.php/3347271). Insane that one should have to do that, though. | [
0.3773934543132782,
0.04412134364247322,
0.36879944801330566,
0.09600607305765152,
0.01694617047905922,
-0.2959839403629303,
0.0518619567155838,
0.055609554052352905,
-0.1984373778104782,
-0.48235437273979187,
0.10649843513965607,
0.8878951668739319,
-0.18061240017414093,
-0.16814854741096... | |
This should be fine seeing as the CLR hasn't actually changed?
The boxes running the C# 2.0 code **have** had .NET 3.5 rolled out.
The background is that we have a windows service (.NET 2.0 exe built with VS2005, deployed to ~150 servers) that dynamically loads assemblies (almost like plug-ins) to complete various work items asked of it. Whenever we roll out a new version of the bus logic, we just drop the assemblies on an FTP server and the windows service knows how to check for, grab and store the latest versions. New assemblies are now built using VS2008 and targetting | [
0.6324561834335327,
-0.06259752064943314,
0.3804530203342438,
-0.0372484028339386,
-0.049447089433670044,
-0.11517217755317688,
0.05013907700777054,
-0.3315373361110687,
-0.43114280700683594,
-0.5451663732528687,
0.12204825133085251,
0.3485316038131714,
-0.2032109946012497,
0.0897314473986... | |
.NET 2.0, we know that works ok. However we'd like to start taking advantage of C# 3.0 language features such as LINQ and targetting the assemblies against .NET 3.5 without having to build and deploy a new version of the windows service.
C#3 and .Net 3.5 adds new assemblies, but the IL is unchanged.
This means that with .Net 2 assemblies you can compile and use C#3, as long as you don't use Linq or anything else that references System.Linq or System.Core
`yield`, `var`, lambda syntax, anon types and initialisers are all compiler cleverness. The IL they produce is cross-compatible.
If you can reference | [
0.5785847902297974,
0.15280334651470184,
0.08664333075284958,
-0.07580066472291946,
-0.43251553177833557,
-0.3703988492488861,
0.2447967827320099,
-0.25325897336006165,
-0.03967803716659546,
-0.9430248141288757,
0.06405069679021835,
0.660323977470398,
-0.5828178524971008,
-0.27351373434066... | |
the new assemblies for 3.5 it should all just work.
There is no new version of ASP.Net - it should still be 2.0.50727 - but you should still compile for 3.5 | [
0.6139291524887085,
0.03486170619726181,
0.5398107171058655,
0.05347069352865219,
-0.1766723394393921,
-0.3221663236618042,
0.3747715353965759,
-0.3529995083808899,
-0.25062790513038635,
-0.677719235420227,
0.08235416561365128,
0.34212538599967957,
-0.0854967013001442,
-0.1410045325756073,... | |
I'm integrating .NET support into our C++ application.
It's an old-school MFC application, with 1 extra file compiled with the "/clr" option that references a CWinFormsControl.
I'm not allowed to remove the linker flag "/NODEFAULTLIB".
(We have our own build management system, not Visual Studio's.)
This means I have to specify all necessary libraries: VC runtime and MFC.
Other compiler options include "/MD"
Next to that: I can't use the linker flag "/FORCE:MULTIPLE" and just add *everything*:
I'm looking for a non-overlapping set of libraries.
I would also suggest checking out the SharePoint Content Deployment Wizard by Chris O'Brien.
<http://www.codeplex.com/SPDeploymentWizard>
Should | [
0.539202868938446,
-0.0293947272002697,
0.30598047375679016,
0.040052831172943115,
-0.10623757541179657,
-0.0625283420085907,
0.1775236427783966,
-0.27726036310195923,
-0.15678472816944122,
-0.7509899735450745,
-0.1491115242242813,
0.5652310252189636,
-0.40353086590766907,
0.06156527251005... | |
help smooth the process you describe, and it's a nice tool for your kitbag regardless | [
0.30869060754776,
0.19290997087955475,
-0.06949079036712646,
0.26445168256759644,
0.08261070400476456,
0.03794609010219574,
0.08834865689277649,
0.30742958188056946,
-0.1442200243473053,
-0.4764028489589691,
0.41692379117012024,
0.47255682945251465,
0.5372124910354614,
-0.16766555607318878... | |
I'm looking for a tool which can generate a [Makefile](https://en.wikipedia.org/wiki/Make_(software)#Makefile) for a C/C++ project for different compilers ([GCC](https://en.wikipedia.org/wiki/GNU_Compiler_Collection), [Microsoft Visual C++](https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B), [C++Builder](https://en.wikipedia.org/wiki/C%2B%2BBuilder), etc.) and different platforms (Windows, Linux, and Mac).
Other suggestions you may want to consider:
* [Scons](http://www.scons.org/) is a cross-platform, cross-compiler build library, uses Python scripting for the build systems. Used in a variety of large projects, and performs very well.
* If you're using [Qt](https://en.wikipedia.org/wiki/Qt_%28software%29), [QMake](https://doc.qt.io/qt-5/qmake-manual.html) is a nice build system too.
* [CMake](https://cmake.org/) is also pretty sweet.
* Finally, [if all else fails...](http://www.google.co.uk/search?q=cross+platform+build+system) | [
0.37275850772857666,
-0.08111383020877838,
0.0687142014503479,
0.1045374870300293,
0.1332452893257141,
0.15800641477108002,
-0.04333743825554848,
0.07574149966239929,
0.05727000907063484,
-0.8174713253974915,
-0.012418658472597599,
0.408120721578598,
0.08314354717731476,
-0.028246132656931... | |
Well, i've got a nice WPF book its called Sams Windows Presentation Foundation Unleashed.
I really like to read and learn with it. Are there any other WPF books you could recommend?
I've found the following books very useful:
[Windows Presentation Foundation Unleashed - Adam Nathan](https://rads.stackoverflow.com/amzn/click/com/0672328917)
You mention you already have this book, however I wanted to give my opinion on it. It is a great book for the newcomer - it is printed in full color which is a great help for visualizing both xaml and concepts for WPF.
[Essential Windows Presentation Foundation - Chris Anderson](https://rads.stackoverflow.com/amzn/click/com/0321374479)
This is also | [
0.41032883524894714,
-0.011874476447701454,
-0.0753200426697731,
0.21684841811656952,
-0.3605223596096039,
-0.34943968057632446,
0.08719427138566971,
0.049396079033613205,
-0.3514581620693207,
-0.7356721758842468,
-0.2373586893081665,
0.6314548254013062,
-0.09709606319665909,
-0.3543200790... | |
another great book for the newcomer. While it is not printed in color, it does give a great insight into how WPF works.
[Pro WPF in C# 2008 - Matthew Macdonald](https://rads.stackoverflow.com/amzn/click/com/1590599551)
This is a great reference book - one that sits on my desk and is constantly referred too. However, I didn't feel is was as newbie friendly as the other two books above. This is the most recently released book (at the time of this posting), and has been updated for VS2008. This is useful, as there are some changes with the versions of WPF. I believe | [
0.11650468409061432,
-0.20400086045265198,
0.4514602720737457,
0.24268025159835815,
-0.10564269870519638,
-0.4408552646636963,
-0.0006707694265060127,
-0.07816183567047119,
-0.3373922109603882,
-0.688044548034668,
0.14603333175182343,
0.2684970498085022,
0.1516346037387848,
0.0719216465950... | |
there is a VB.NET version available.
[Programming WPF - Chris Sells & Ian Griffiths](https://rads.stackoverflow.com/amzn/click/com/0596510373)
Another great book - I wish this was available when I was first learning the framework.
[Application = Code + Markup - Charles Petzold](https://rads.stackoverflow.com/amzn/click/com/0735619573)
This was the very first WPF I purchased. It is *not* very newbie friendly, and I wouldn't recommend it for a first-time-wpf'er. The fact that Xaml is not introduced until page 457 makes learning the technology for the real world very difficult. That said, this book is invaluable if you really want to understand how things work at | [
0.3837336003780365,
0.10758382081985474,
0.24929066002368927,
0.07531452924013138,
-0.012248937971889973,
-0.44319644570350647,
0.224554181098938,
-0.2705139219760895,
-0.3320232629776001,
-0.5273808240890503,
-0.13740195333957672,
0.35100629925727844,
-0.2740500867366791,
-0.1850158870220... | |
a very deep level (which is also important to get the most of the framework.
The only book I would totally avoid is:
[Professional WPF Programming - Chris Andrade et al.](https://rads.stackoverflow.com/amzn/click/com/0470041803)
While the content was Ok in this book, I just found the other books to be much clearer and delve to a much deeper level.
Hope this helps! WPF has a steep learning curve, but once you "get it", UI programming can actually become "fun"! | [
0.11287407577037811,
-0.17531608045101166,
0.17075449228286743,
0.3700738251209259,
-0.21790869534015656,
-0.5258194208145142,
0.45415741205215454,
-0.04566565155982971,
-0.19829265773296356,
-0.40723153948783875,
-0.07567135989665985,
0.5780049562454224,
0.372015118598938,
-0.117459051311... | |
Apparantly when users right-click in our WPF application, and they use the Windows Classic theme, the default ContextMenu of the TextBox (which contains Copy, Cut and Paste) has a black background.
I know this works well:
```
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBox ContextMenu="{x:Null}"/>
</Page>
```
But this doesn't work:
```
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
<Setter Property="ContextMenu" Value="{x:Null}"/>
</Style>
</Page.Resources>
<TextBox/>
</Page>
```
Does anyone know how to style or disable the default ContextMenu for all TextBoxes in WPF?
Due to a late bug report we discovered that we cannot use the ApplicationComands Cut Paste and Copy | [
-0.07545343786478043,
0.2607426643371582,
0.4287075102329254,
-0.25984320044517517,
-0.19167117774486542,
-0.03703903779387474,
0.5806049704551697,
-0.3223971724510193,
-0.17916260659694672,
-0.222417414188385,
-0.23022472858428955,
0.7730944752693176,
-0.6016756892204285,
0.11797215789556... | |
directly in a partial trusted application. Therefor, using these commands in any Commmand of your controls will do absolutely nothing when executed.
So in essence Brads answer was almost there, it sure looked the right way i.e. no black background, but did not fix the problem.
We decided to "remove" the menu based on Brads answer, like so:
```
<ContextMenu x:Key="TextBoxContextMenu" Width="0" Height="0" />
```
And use this empty context menu like so:
```
<Style TargetType="{x:Type TextBox}">
<Setter Property="ContextMenu" Value="{StaticResource TextBoxContextMenu}" />
</Style>
``` | [
0.09703899174928665,
0.012039470486342907,
0.4075930416584015,
0.06408669054508209,
0.08401469886302948,
0.06582033634185791,
0.1774866282939911,
-0.41370683908462524,
0.14975759387016296,
-0.4791031777858734,
-0.12342122197151184,
0.7643047571182251,
-0.22091597318649292,
-0.0846516042947... | |
I've been raised to believe that if multiple threads can access a variable, then all reads from and writes to that variable must be protected by synchronization code, such as a "lock" statement, because the processor might switch to another thread halfway through a write.
However, I was looking through System.Web.Security.Membership using Reflector and found code like this:
```
public static class Membership
{
private static bool s_Initialized = false;
private static object s_lock = new object();
private static MembershipProvider s_Provider;
public static MembershipProvider Provider
{ | [
0.4368952214717865,
-0.0529845729470253,
0.36845237016677856,
-0.15659289062023163,
0.2193668931722641,
-0.10770606249570847,
0.304522305727005,
-0.22000154852867126,
-0.3301794230937958,
-0.3236018419265747,
-0.014881543815135956,
0.3597806394100189,
-0.3279467523097992,
0.572484374046325... | |
get
{
Initialize();
return s_Provider;
}
}
private static void Initialize()
{
if (s_Initialized)
return;
lock(s_lock)
{ | [
0.08722361922264099,
-0.442932665348053,
0.19904404878616333,
-0.11791462451219559,
0.2683747410774231,
0.12808942794799805,
0.3087528944015503,
-0.32379284501075745,
0.042112600058317184,
-0.7132275104522705,
-0.7329832911491394,
0.12088970839977264,
-0.24685996770858765,
0.16767518222332... | |
if (s_Initialized)
return;
// Perform initialization...
s_Initialized = true;
}
}
}
```
Why is the s\_Initialized field read outside of the lock? Couldn't another thread be trying to write to it at the same time? **Are reads and writes of variables atomic?**
For the definitive answer go | [
-0.08852417767047882,
-0.01671563647687435,
0.2651313543319702,
-0.07435917109251022,
0.2139264941215515,
-0.17308790981769562,
0.2584962546825409,
-0.20452696084976196,
-0.2893446683883667,
-0.48561516404151917,
-0.25510093569755554,
0.2191566675901413,
-0.2872999608516693,
0.274249285459... | |
to the spec. :)
Partition I, Section 12.6.6 of the CLI spec states: "A conforming CLI shall guarantee that read and write access to properly aligned memory locations no larger than the native word size is atomic when all the write accesses to a location are the same size."
So that confirms that s\_Initialized will never be unstable, and that read and writes to primitve types smaller than 32 bits are atomic.
In particular, `double` and `long` (`Int64` and `UInt64`) are **not** guaranteed to be atomic on a 32-bit platform. You can use the methods on the `Interlocked` class to protect these.
Additionally, while | [
0.18495824933052063,
0.2606552243232727,
0.4453628957271576,
0.10511460155248642,
0.6131114363670349,
-0.3023969531059265,
-0.07714492827653885,
-0.1550416201353073,
-0.23598790168762207,
-0.22429564595222473,
-0.4243667721748352,
0.45552706718444824,
-0.22995328903198242,
0.16588987410068... | |
reads and writes are atomic, there is a race condition with addition, subtraction, and incrementing and decrementing primitive types, since they must be read, operated on, and rewritten. The interlocked class allows you to protect these using the `CompareExchange` and `Increment` methods.
Interlocking creates a memory barrier to prevent the processor from reordering reads and writes. The lock creates the only required barrier in this example. | [
0.04154910892248154,
0.32394132018089294,
-0.2020035982131958,
0.4240887463092804,
0.3019199073314667,
0.06641122698783875,
0.21206443011760712,
-0.19571325182914734,
-0.039770834147930145,
-0.42580974102020264,
0.03420714661478996,
0.5042792558670044,
-0.3387989401817322,
0.33445262908935... | |
Given a handle of type `HWND` is it possible to confirm that the handle represents a real window?
There is a function `IsWindow` which does exactly what you asked for.
```
BOOL isRealHandle = IsWindow(unknwodnHandle);
```
Look at [this link](http://msdn.microsoft.com/en-us/library/ms633528(VS.85).aspx) for more information. | [
-0.048196107149124146,
0.0640997588634491,
0.40030619502067566,
0.035498932003974915,
-0.19286949932575226,
-0.1744493991136551,
0.16538238525390625,
0.0002615497214719653,
-0.28002819418907166,
-0.681413471698761,
-0.22879444062709808,
0.4179424047470093,
-0.07599630206823349,
0.225984185... | |
I'm implementing a document server. Currently, if two users open the same document, then modify it and save the changes, the document's state will be undefined (either the first user's changes are saved permanently, or the second's). This is entirely unsatisfactory. I considered two possibilities to solve this problem:
The first is to lock the document when it is opened by someone the first time, and unlock it when it is closed. But if the network connection to the server is suddenly interrupted, the document would stay in a forever-locked state. The obvious solution is to send regular pings to the | [
0.16329823434352875,
0.08731742948293686,
0.6508086919784546,
0.030465610325336456,
0.3167944550514221,
-0.27371466159820557,
0.21649186313152313,
-0.13969004154205322,
-0.34341394901275635,
-0.6586148738861084,
-0.12893146276474,
0.38490018248558044,
-0.3307320475578308,
0.391616642475128... | |
server. If the server doesn't receive K pings in a row (K > 1) from a particular client, documents locked by this client are unlocked. If that client re-appears, documents are locked again, if someone hadn't already locked them. This could also help if the client application (running in web browser) is terminated unexpectedly, making it impossible to send a 'quitting, unlock my documents' signal to the server.
The second is to store multiple versions of the same document saved by different users. If changes to the document are made in rapid succession, the system would offer either to merge versions | [
-0.05312584713101387,
-0.07556413859128952,
0.5244308114051819,
0.07967400550842285,
0.08342013508081436,
-0.1343507170677185,
0.4552728533744812,
-0.222617968916893,
-0.5839948058128357,
-0.5535754561424255,
-0.4067409336566925,
0.1576717644929886,
-0.34919819235801697,
0.5364201664924622... | |
or to select a preferred version. To optimize storage space, only document diffs should be kept (just like source control software).
What method should I choose, taking into consideration that the connection to the server might *sometimes* be slow and unresponsive? How should the parameters (ping interval, rapid succession interval) be determined?
P.S. Unfortunately, I can't store the documents in a database.
My suggestion would be something like your first one. When the first user (Bob) opens the document, he acquires a lock so that other users can only read the current document. If the user saves the document while he is using | [
0.3056897521018982,
0.18277639150619507,
0.5027498602867126,
0.05530710890889168,
0.35491228103637695,
-0.18335428833961487,
0.25874966382980347,
-0.18121637403964996,
-0.3761788010597229,
-0.5710615515708923,
-0.13974061608314514,
0.6261826753616333,
-0.19849033653736115,
0.15406882762908... | |
it, he keeps the lock. Only when he exits the document, it is unlocked and other people can edit it.
If the second user (Kate) opens the document while Bob has the lock on it, Kate will get a message saying the document is uneditable but she can read it until it the lock has been released.
So what happens when Bob acquires the lock, maybe saves the document once or twice but then exits the application leaving the lock hanging?
As you said yourself, requiring the client with the lock to send pings at a certain frequency is probably the | [
0.30099210143089294,
-0.026966623961925507,
0.45502424240112305,
0.04528084397315979,
0.4940427243709564,
-0.23795340955257416,
0.3174119293689728,
-0.2681553065776825,
-0.64537513256073,
-0.03915407508611679,
-0.2877843379974365,
0.49598801136016846,
-0.19181185960769653,
0.09004544466733... | |
best option. If you don't get a ping from the client for a set amount of time, this effectively means his client is not responding anymore. If this is a web application you can use javascript for the pings. The document that was last saved releases its lock and Kate can now acquire it.
A ping can contain the name of the document that the client has a lock on, and the server can calculate when the last ping for that document was received. | [
-0.23648713529109955,
-0.39054566621780396,
0.5784323811531067,
0.26630544662475586,
0.21564126014709473,
-0.22552675008773804,
0.23921513557434082,
-0.32237812876701355,
-0.17078152298927307,
-0.7165332436561584,
-0.060364268720149994,
0.4386739134788513,
0.014496132731437683,
-0.14676995... | |
As part of our current database work, we are looking at a dealing with the process of updating databases.
A point which has been brought up recurrently, is that of dealing with system vs. user values; in our project user and system vals are stored together. For example...
We have a list of templates.
```
1, <system template>
2, <system template>
3, <system template>
```
These are mapped in the app to an enum (1, 2, 3)
Then a user comes in and adds...
```
4, <user template>
```
...and...
```
5, <user template>
```
Then.. we issue an upgrade.. and insert as part of our upgrade scripts...
```
<new id> [6], <new system template>
```
THEN!!... we find a bug | [
0.28100356459617615,
0.2061121016740799,
0.35235387086868286,
0.2774498760700226,
0.4528861939907074,
0.19724412262439728,
0.0851815864443779,
-0.30845969915390015,
-0.14728443324565887,
-0.8330394625663757,
-0.22824831306934357,
0.6295824646949768,
-0.3878057897090912,
-0.0725867077708244... | |
in the new system template and need to update it... The problem is how? We cannot update record using ID6 (as we may have inserted it as 9, or 999, so we have to identify the record using some other mechanism)
So, we've come to two possible solutions for this.
**In the red corner (speed)....**
---------------------------------
We simply start user Ids at 5000 (or some other value) and test data at 10000 (or some other value). This would allow us to make modifications to system values and test them up to the lower limit of the next ID range.
Advantage...Quick and easy to implement, | [
0.18599392473697662,
0.015513820573687553,
0.545780599117279,
0.4561348557472229,
0.20899924635887146,
0.057177357375621796,
-0.14032188057899475,
-0.3290367126464844,
-0.42923542857170105,
-0.9387437105178833,
0.10292653739452362,
0.529081404209137,
0.1137813851237297,
0.21240079402923584... | |
Disadvantage... could run out of values if we don't choose a big enough range!
**In the blue corner (scalability)...**
---------------------------------------
We store, system and user data separately, use GUIDs as Ids and merge the two lists using a view.
Advantage...Scalable..No limits w/regard to DB size.
Disadvantage.. More complicated to implement. (many to one updatable views etc.)
---
I plump squarely for the first option, but looking for some ammo to back me up!
Does anyone have any thoughts on these approaches, or even one(s) that we've missed?
I have never had problems (performance or development - TDD & unit testing included) using GUIDs as the ID for my | [
0.00861196219921112,
0.10126551240682602,
0.38200849294662476,
-0.018469324335455894,
-0.2473198026418686,
0.21194101870059967,
0.011898667551577091,
-0.21572811901569366,
-0.009392458014190197,
-0.7974638938903809,
0.11765197664499283,
0.734301745891571,
-0.039174046367406845,
-0.03357836... | |
databases, and I've worked on some pretty big ones. Have a look [here](http://www.sql-server-performance.com/articles/per/guid_performance_p2.aspx), [here](http://weblogs.asp.net/wwright/archive/2007/11/04/the-gospel-of-the-guid-and-why-it-matters.aspx) and [here](http://weblogs.asp.net/wwright/archive/2007/11/11/gospel-of-the-guid-answers-to-your-burning-questions-comments-and-insults.aspx) if you want to find out more about using GUIDs (and the potential GOTCHAS involved) as your primary keys - but I can't recommend it highly enough since moving data around safely and DB synchronisation becomes as easy as brushing your teeth in the morning :-)
For your question above, I would either recommend a third column (if possible) that indicates whether or not the template is user or system based, or you can at the very least generate GUIDs for system templates as you | [
0.37019476294517517,
0.4684065282344818,
0.1505592167377472,
0.15978047251701355,
-0.4686696529388428,
-0.11695390939712524,
0.17682801187038422,
-0.018961627036333084,
-0.19866348803043365,
-0.5208401083946228,
0.0905877947807312,
0.9284785985946655,
-0.28314924240112305,
-0.4839669466018... | |
insert them and keep a list of those on hand, so that if you need to update the template, you can just target that same GUID in your DEV, UAT and /or PRODUCTION databases without fear of overwriting other templates. The third column would come in handy though for selecting all system or user templates at will, without the need to seperate them into two tables (this is overkill IMHO).
I hope that helps,
Rob G | [
0.5305503010749817,
0.08927847445011139,
-0.06196175888180733,
0.18368805944919586,
0.07601302862167358,
-0.15399199724197388,
0.02962946519255638,
0.0149465287104249,
-0.1456030160188675,
-0.7561522126197815,
0.1798747330904007,
0.668423593044281,
-0.3159620463848114,
-0.397319495677948,
... | |
I'm starting a new project here (Windows Forms). What's the best option today for a small (free as in beer) DBMS?
I've used SQL Server Express on the past projects, but time and time again I hear people saying that the product from Oracle is faster and more powerful.
It will be used in a small company (around 20 users) and will not reach the 4 GB limit any time soon :)
I don't want to start a flame war on my first post, so please point me to some link showing a good (and actual) comparison between the 2 products, if possible.
PS: | [
0.5512589812278748,
0.22738797962665558,
0.21471230685710907,
0.10501264035701752,
-0.3270232677459717,
-0.3169220983982086,
0.31051865220069885,
-0.09413504600524902,
-0.04147239774465561,
-0.7181019186973572,
0.10895778983831406,
0.35875701904296875,
-0.06239061802625656,
0.0302853882312... | |
I've heard about [IBM DB2 Express](http://en.wikipedia.org/wiki/IBM_DB2_Express-C) too, but I coudn't find any information about it. (Marketing material from IBM doesn't count :) )
Sorry, no link, but one advice. Because we support Oracle and SQL Server, I know that getting fixes for the 'normal' Oracle database, is not something what I call fun. You have to pay for it, and if you have no tool which updates your Oracle system for you, it's a pain in the a.., if you ask me. Check out how the Oracle XE is supported with updates/fixes. I don't know, I only use the 'normal' Oracle | [
0.21915872395038605,
0.2723262310028076,
-0.1918085366487503,
0.2546660602092743,
-0.3078424632549286,
-0.09325194358825684,
0.39067038893699646,
0.6213763952255249,
-0.22601604461669922,
-0.24713556468486786,
0.16792911291122437,
0.533719003200531,
-0.29166316986083984,
0.0474512353539466... | |
(Developer) database. | [
0.22921372950077057,
0.10820522159337997,
-0.11570911109447479,
0.2197408378124237,
0.16910609602928162,
0.020536182448267937,
-0.2166585773229599,
-0.22257740795612335,
0.007037284784018993,
-0.4396742284297943,
-0.14176154136657715,
0.0987391322851181,
-0.17661075294017792,
0.37601119279... | |
I've been tasked with updating a series of applications which are performance critical VB.NET apps that essentially just monitor and return networking statistics. I've only got three requirements: *convert it to C#, make it fast, and make it stable*
One caveat is that we *"may"* migrate from a .NET platform to linux *"soon"*
I will be responsible for maintaining these apps in the future so I'd like to do this right. I have decided to refactor these apps according to the MVP pattern so that I can properly unit test the hell out of this bad boy. But I was also thinking | [
0.5616060495376587,
0.4143756031990051,
0.41821566224098206,
0.0654769316315651,
0.09254050254821777,
-0.26832035183906555,
0.30270251631736755,
0.2002410590648651,
-0.049790505319833755,
-0.8800431489944458,
0.01375733595341444,
0.7457327246665955,
-0.1308138072490692,
-0.1187949776649475... | |
since I was using MVP that I could also do the computationally expensive stuff in native C/C++ code while the GUI would be done with .NET forms, or Qt or whatever.
questions:
1. does it make sense to do a GUI in winforms but the expensive stuff in native, unmanaged C/C++ ?
2. any recommendations for a good cross platform windowing kit that would fit for the scenario described above?
First off, I would put some time into trying out a few [VB.NET to C# converters](http://www.google.com/search?q=VB.NET+to+C%23+converter&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a). You're basically porting syntax, and there's no reason to do that by hand if you don't have | [
0.060428258031606674,
-0.01081616710871458,
-0.014880066737532616,
0.1913652867078781,
-0.19209004938602448,
-0.18413209915161133,
0.21190446615219116,
-0.07182028889656067,
-0.14731428027153015,
-0.991682231426239,
0.11410564184188843,
0.6424021124839783,
-0.503558337688446,
-0.1567147374... | |
to. Sure, you might have to clean up what comes out of the converter, but that's way better than a by-hand conversion.
Now, as for your questions:
> 1) does it make sense to do a GUI in winforms but the expensive stuff in native, unmanaged C/C++ ?
Not yet. Wait until you've done the conversion, and then find out where you're actually spending your time. There's no reason to jump into mixing C/C++ with C# until you find out that it's necessary. You may find that dropping into unsafe C# is sufficient. Even that may be unnecessary. You might just need to | [
0.4139534831047058,
-0.12415046244859695,
-0.1012050062417984,
0.061255600303411484,
0.10127495229244232,
-0.2219546139240265,
0.3597318232059479,
-0.10778176039457321,
0.2569326162338257,
-0.6254035234451294,
-0.11243228614330292,
0.9574148654937744,
-0.1705736368894577,
-0.29838117957115... | |
optimize algorithms. Find out what your bottlenecks are and *then* decide how to fix them.
> 2) any recommendations for a good cross platform windowing kit that would fit for the scenario described above?
I'd be looking into [mono](http://www.mono-project.com) for sure. That's really the best you can do if you're going with C#. It's pretty much either mono or another rewrite in another language when/if you move to Linux. | [
0.540925920009613,
-0.16193410754203796,
-0.23824015259742737,
0.05546579882502556,
-0.11310743540525436,
-0.04249255731701851,
0.140665665268898,
0.18122002482414246,
-0.26959195733070374,
-0.5792055726051331,
-0.15534818172454834,
0.9232195615768433,
-0.26674115657806396,
-0.461796224117... | |
I'm currently trying to build a personal website to create a presence on the web for myself. My plan is to include content such as my resume, any projects that I have done on my own and links to open source projects that I have contributed to, and so on. However, I'm not sure which approach would be better from a perspective of "advertising" myself, since that what this site does, especially since I am a software developer.
Should I use an out-of-the-box system and extend it as needed, with available modules and custom modules where needed or should I custom | [
0.9289645552635193,
0.2466180920600891,
0.1137891560792923,
-0.17519113421440125,
-0.027400586754083633,
0.0957513153553009,
0.169540137052536,
0.4228014051914215,
-0.3073614835739136,
-0.5217175483703613,
0.24209396541118622,
0.2234383225440979,
0.12197060883045197,
0.3148052990436554,
... | |
build a site and all of its features as I need them? Does a custom site look better in the eyes of a potential employer who might visit my site?
I've toyed with this idea in the past but I don't think it's really a good idea for a number of reasons. Firstly, there are a number of places that can take care of most of this without you needing to do the work or maintenance. Just signing up for a linkedIn account for example will allow you to get most of your needs catered for in this regard. You can | [
1.1038752794265747,
0.22744950652122498,
0.19666460156440735,
-0.049450527876615524,
0.14751307666301727,
0.4017469882965088,
0.3794149160385132,
-0.022671282291412354,
-0.17920821905136108,
-0.585070788860321,
0.22394268214702606,
0.49345096945762634,
0.20444446802139282,
0.21733815968036... | |
create your resume there and bio information etc and make it publicly viewable. The other issue with your "own site" is that if you don't update it often, the information gets stale, and worse yet, people have no reason to go back because *"nothing has changed"* - and that's not much of an *advert* for you is it?
Now that I've said all that, I'll make another recommendation. Why not start a blog instead?! If you've got decent experience, why not share that. I'd be willing to bet that this will be the *best* advert for your skills because:
1. It's always | [
1.2161434888839722,
0.04119746387004852,
0.14317266643047333,
0.16134443879127502,
-0.01899290643632412,
-0.4650364816188812,
0.16425856947898865,
0.662982165813446,
-0.41090479493141174,
-0.44449564814567566,
0.36348575353622437,
0.4273850917816162,
0.2172609120607376,
-0.0736885294318199... | |
updated (if you post often)
2. It's not like you're *looking* for work doing it - but your (future) employer, or their developers will check it out anyway to get a better insight into your character.
3. Putting something on your resume doesn't mean you can do it. I'm not saying that you'd lie about your skills :-), but there's no argument about your ability when you're writing articles about the stuff, getting comments and feedback, and better yet, learning *EVEN MORE* about your passions.
Best of all - you can run your blog from your chosen domain and also point to your | [
0.7193832397460938,
-0.1634037345647812,
0.33686092495918274,
0.32738950848579407,
-0.15528130531311035,
-0.25907987356185913,
0.2652883529663086,
0.48266854882240295,
-0.16049356758594513,
-0.47020336985588074,
-0.04694478213787079,
0.4852854907512665,
0.07659976184368134,
-0.391105949878... | |
resume that is stored in linkedIn. Just an idea...
That's my two pennys worth on that - hope it helps you come to a decision! | [
0.4220500886440277,
0.002766042249277234,
0.503708004951477,
0.23851622641086578,
0.3215876519680023,
-0.07920806109905243,
-0.0024333682376891375,
0.36661073565483093,
-0.33527106046676636,
-0.5240800976753235,
0.38428962230682373,
0.38521772623062134,
0.23313596844673157,
-0.356245905160... | |
We have a codebase that is several years old, and all the original developers are long gone. It uses many, many threads, but with no apparent design or common architectural principles. Every developer had his own style of multithreaded programming, so some threads communicate with one another using queues, some lock data with mutexes, some lock with semaphores, some use operating-system IPC mechanisms for intra-process communications. There is no design documentation, and comments are sparse. It's a mess, and it seems that whenever we try to refactor the code or add new functionality, we introduce deadlocks or other problems.
So, does | [
0.543651819229126,
0.4518802762031555,
0.08513729274272919,
0.3248349130153656,
0.4167727530002594,
-0.0639268234372139,
0.062045324593782425,
0.3057529330253601,
-0.06312908977270126,
-0.4986957609653473,
0.12284991890192032,
-0.13278405368328094,
-0.355115681886673,
0.45559161901474,
-... | |
anyone know of any tools or techniques that would help to analyze and document all the interactions between threads? FWIW, the codebase is C++ on Linux, but I'd be interested to hear about tools for other environments.
---
Update
------
I appreciate the responses received so far, but I was hoping for something more sophisticated or systematic than advice that is essentially "add log messages, figure out what's going on, and fix it." There are lots of tools out there for analyzing and documenting control-flow in single-threaded programs; is there nothing available for multi-threaded programs?
---
See also [Debugging multithreaded applications](https://stackoverflow.com/questions/619677/debugging-multithreaded-applications)
Invest in a copy of Intel's | [
0.30792519450187683,
0.19577112793922424,
-0.03543904423713684,
0.43853795528411865,
0.043968167155981064,
-0.3038528263568878,
0.15018388628959656,
0.3109775185585022,
-0.40516161918640137,
-0.38297945261001587,
0.011593503877520561,
0.602607786655426,
-0.20806141197681427,
0.005477391183... | |
[VTune](http://www.intel.com/cd/software/products/asmo-na/eng/239144.htm) and its thread profiling tools. It will give you both a system and a source level view of the thread behaviour. It's certainly not going to autodocument the thing for you, but should be a real help in at least visualising what is happening in different circumstances.
I think there is a trial version that you can download, so may be worth giving that a go. I've only used the Windows version, but looking at the VTune webpage it also has a Linux version. | [
0.4635266959667206,
-0.12552691996097565,
0.23157598078250885,
0.024009931832551956,
-0.28132936358451843,
-0.19800400733947754,
0.35927852988243103,
0.37698864936828613,
-0.17460432648658752,
-0.3977099657058716,
-0.028743499889969826,
0.7350320219993591,
-0.06397359818220139,
0.213122472... | |
I have an application deployed into multiple zones and there are some issues with opening larger documents (20-50MB) across the WAN.
Currently the documents are stored in Zone 1 (Americas) and a link stored in the database to the docs.
I have heard some things about blobs in oracle and store binary in MS SQL Server 2005 and then perhaps copying the database to other zones.
Any other suggestions or good results with one of the described options?
Your best option here may be caching the document in the requested zone the first time it is requested, and pinging the source document's | [
0.2489067167043686,
0.08063944429159164,
0.5520950555801392,
0.11818907409906387,
0.34646084904670715,
-0.26901736855506897,
-0.06563416123390198,
0.1968974471092224,
-0.4222972095012665,
-0.6356214284896851,
-0.05901165306568146,
0.06971925497055054,
0.0930284783244133,
0.2438011169433593... | |
last modified each time the cached document is requested in order to determine if it needs refreshed. In this case you're only requesting a small piece of information (a date) across the WAN most of the times the document is accessed. This works best for a subset of documents that are frequently requested.
If you have a large set of documents, each infrequently requested by a disparate group, then you may want to look into replicating the documents in each of your zones each time the master is updated. This may best be accomplished by storing the document as binary | [
0.13792768120765686,
-0.3010951578617096,
0.4385679364204407,
0.2534931004047394,
0.0479901060461998,
0.03568790853023529,
0.1499524712562561,
-0.09126162528991699,
-0.6938329339027405,
-0.6589433550834656,
-0.3242407739162445,
0.2443380206823349,
0.03088560327887535,
0.3572941720485687,
... | |
data in your master database and having the slaves pull from the master. | [
0.5725401639938354,
-0.0991063341498375,
-0.0739889144897461,
0.5138896107673645,
0.15248797833919525,
-0.05454283952713013,
-0.40757909417152405,
-0.0929563120007515,
-0.2138158679008484,
-0.5108975768089294,
0.1551971286535263,
0.5757197141647339,
-0.2598051130771637,
0.21352437138557434... | |
I am trying to find a generic way of accessing a set of containers. I have a standard vector and list in addition to another custom list.
The custom list defines an iterator;
```
class Iterator: public std::iterator<std::forward_iterator_tag, T> {
// ...
}
Iterator begin() {
return (Iterator(root));
}
Iterator end() {
return (Iterator(NULL));
}
```
with the appropriate operators overloaded.
Ideally, I would like to do this;
```
class Foo {
public:
Foo() {
std::list<int> x;
std::vector<int> y;
custom_list<int> | [
-0.16307364404201508,
0.04937879368662834,
0.3847232758998871,
-0.25228220224380493,
-0.059542909264564514,
0.4247743487358093,
-0.06197110936045647,
-0.6154910922050476,
-0.2370203584432602,
-0.4768308699131012,
0.011297815479338169,
0.6127069592475891,
-0.3551512062549591,
0.252826213836... | |
z;
iter = x.begin(); // OR
iter = y.begin(); // OR
iter = z.begin();
// ...
};
private:
std::iterator<int> iter;
};
```
But obviously these are all iterators of different types. I can assume all the containers are of the same type however.
Is there an elegant way to solve this problem?
Here are some articles you might find of interest
[Giving STL Iterators a Base Class](http://accu.org/index.php/journals/479)
[Type Erasure for C++ Iterators](http://thbecker.net/free_software_utilities/type_erasure_for_cpp_iterators/start_page.html)
[any\_iterator Class Reference](http://stlab.adobe.com/classadobe_1_1any__iterator.html) | [
-0.12987248599529266,
0.2785358428955078,
0.43449753522872925,
-0.029944557696580887,
-0.043372757732868195,
-0.05424293875694275,
-0.12451744824647903,
-0.3967164158821106,
-0.4234771132469177,
-0.19165991246700287,
-0.4581635594367981,
0.6523284912109375,
-0.39079856872558594,
0.30930569... | |
I understand how JS is run and I think I understand most of the DOM but I've no idea about animation. Does anybody here know of a good guide that can explain to me how it's done in Javascript?
In addition, should I even consider Javascript for animation? Should I instead be looking to learn flash?
Avoid flash, its a horrible requirement, uncrawlable by Google, unsopported by a bunch of browsers and systems (eg iPhone) and most importantly: it forces you to reinvent web standards (e.g. scroll bars and whatnot), Javascript on the other hand is easier to maintain and code for | [
0.4591843783855438,
0.23297587037086487,
0.09065236151218414,
0.1829051524400711,
-0.2606273591518402,
-0.289657860994339,
0.407299280166626,
0.18103225529193878,
-0.19790129363536835,
-0.5682717561721802,
-0.1447599083185196,
0.6242920160293579,
-0.12781286239624023,
-0.24101082980632782,... | |
in the noscript case.
try [scriptaculous](http://script.aculo.us/) for your animations;
* [here's a quickie 3-line tutorial so
you can see it working](http://woork.blogspot.com/2008/01/toggle-effect-using-scriptaculous.html)
* [here's a more complete tutorial](http://www.tutorialspoint.com/script.aculo.us/index.htm)
* [here's the scriptaculous wiki](http://github.com/madrobby/scriptaculous/wikis)
note that there are a gazillion JS animation libraries, some really good [jQuery](http://jquery.com/) comes to mind. Usually they're just a script tag and an onclick event to setup.
Good luck!
/mp | [
0.30794015526771545,
-0.2592163681983948,
0.3852762281894684,
0.36991384625434875,
-0.1001264676451683,
-0.06927258521318436,
0.1655585616827011,
0.2290855497121811,
-0.3296750485897064,
-0.7476984858512878,
-0.061204712837934494,
0.5890184044837952,
-0.01976701430976391,
-0.11670380830764... | |
I'm working on an app that grabs and installs a bunch of updates off an an external server, and need some help with threading. The user follows this process:
* Clicks button
* Method checks for updates, count is returned.
* If greater than 0, then ask the user if they want to install using MessageBox.Show().
* If yes, it runs through a loop and call BeginInvoke() on the run() method of each update to run it in the background.
* My update class has some events that are used to update a progress bar etc.
The progress bar updates are fine, but the MessageBox is | [
0.7018663287162781,
0.03689703345298767,
0.3866543769836426,
-0.08205070346593857,
0.01990978792309761,
-0.15087760984897614,
0.44763419032096863,
0.1403682976961136,
-0.018049031496047974,
-0.7595092058181763,
0.007779593113809824,
0.4437265992164612,
-0.18616290390491486,
0.1230055913329... | |
not fully cleared from the screen because the update loop starts right after the user clicks yes (see screenshot below).
* What should I do to make the messagebox disappear instantly before the update loop starts?
* Should I be using Threads instead of BeginInvoke()?
* Should I be doing the initial update check on a separate thread and calling MessageBox.Show() from that thread?
**Code**
```
// Button clicked event handler code...
DialogResult dlgRes = MessageBox.Show(
string.Format("There are {0} updates available.\n\nInstall these now?",
um2.Updates.Count), "Updates Available",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question, | [
0.08068745583295822,
-0.0994114875793457,
0.7863512635231018,
-0.08255121856927872,
0.2464705854654312,
-0.08504719287157059,
0.6654583215713501,
0.01121758483350277,
-0.32250460982322693,
-0.6000590324401855,
-0.24810148775577545,
0.541413426399231,
-0.35180243849754333,
0.422712713479995... | |
MessageBoxDefaultButton.Button2
);
if (dlgRes == DialogResult.Yes)
{
ProcessAllUpdates(um2);
}
// Processes a bunch of items in a loop
private void ProcessAllUpdates(UpdateManager2 um2)
{
for (int i = 0; i < um2.Updates.Count; i++)
{
Update2 update = um2.Updates[i];
ProcessSingleUpdate(update);
int percentComplete = Utilities.CalculatePercentCompleted(i, um2.Updates.Count);
UpdateOverallProgress(percentComplete);
}
}
// Process a single update with IAsyncResult
private void ProcessSingleUpdate(Update2 update)
{
update.Action.OnStart += Action_OnStart;
update.Action.OnProgress += Action_OnProgress; | [
-0.07270249724388123,
-0.38797682523727417,
0.7552018165588379,
-0.22893521189689636,
0.14282697439193726,
0.47229403257369995,
0.6230186223983765,
-0.5616031289100647,
-0.30903807282447815,
-0.4080200493335724,
-0.356376051902771,
0.5277261734008789,
-0.5862648487091064,
0.036823667585849... | |
update.Action.OnCompletion += Action_OnCompletion;
//synchronous
//update.Action.Run();
// async
IAsyncResult ar = this.BeginInvoke((MethodInvoker)delegate() { update.Action.Run(); });
}
```
**Screenshot**
[](http://www.flickr.com/photos/brianly/2760435228/ "Windows Mobile Bug by BrianLy, on Flickr")
Your UI isn't updating because all the work is happening in the user interface thread.
Your call to:
```
this.BeginInvoke((MethodInvoker)delegate() {update.Action.Run(); })
```
is saying invoke update.Action.Run() on the thread that created "this" (your form), which is the user interface thread.
```
Application.DoEvents()
```
will indeed give the UI thread the chance to redraw the screen, but I'd be tempted to create new delegate, and call BeginInvoke on that.
This | [
0.12513922154903412,
0.15201199054718018,
0.46849381923675537,
-0.32991597056388855,
0.2531254291534424,
0.0010132687166333199,
0.5029193758964539,
-0.33920857310295105,
-0.600877046585083,
-0.5671829581260681,
-0.32619625329971313,
0.6616575717926025,
-0.7484350204467773,
-0.0170093812048... | |
will execute the update.Action.Run() function on a seperate thread allocated from the thread pool. You can then keep checking the IAsyncResult until the update is complete, querying the update object for its progress after every check (because you can't have the other thread update the progress bar/UI), then calling Application.DoEvents().
You also are supposed to call EndInvoke() afterwards otherwise you may end up leaking resources
I would also be tempted to put a cancel button on the progress dialog, and add a timeout, otherwise if the update gets stuck (or takes too long) then your application will have locked up forever. | [
0.4264664947986603,
-0.22600696980953217,
0.5117576122283936,
0.15655910968780518,
0.4028383791446686,
-0.21399062871932983,
0.5115607976913452,
-0.17162421345710754,
-0.23490655422210693,
-0.9809248447418213,
-0.10929202288389206,
0.738995373249054,
-0.42963147163391113,
0.051657505333423... | |
How do I write code where a company icon appears on the left side next to the URL address in the browser's address bar?
You are looking for a [Favicon](https://stackoverflow.com/questions/6642/preferred-way-to-use-favicons#6645). | [
0.3682972490787506,
0.15489578247070312,
0.5591381788253784,
-0.006747527047991753,
0.36473900079727173,
-0.14459723234176636,
0.14848263561725616,
0.06380511820316315,
-0.034652501344680786,
-0.33265581727027893,
-0.05308590829372406,
0.3294545114040375,
-0.03095497377216816,
-0.017833212... | |
When should I **not** use the ThreadPool in .Net?
It looks like the best option is to use a ThreadPool, in which case, why is it not the only option?
What are your experiences around this?
The only reason why I wouldn't use the `ThreadPool` for cheap multithreading is if I need to…
1. interract with the method running (e.g., to kill it)
2. run code on a [STA thread](http://msdn.microsoft.com/en-us/library/system.stathreadattribute.aspx "Single-Threaded Apartment thread; see e.g. this MSDN reference page for STAThreadAttribute") (this happened to me)
3. keep the thread alive after my application has died (`ThreadPool` threads are background threads)
4. in case I need to change | [
0.5647043585777283,
-0.1579376459121704,
0.19626015424728394,
0.16186542809009552,
-0.004796082619577646,
-0.37097954750061035,
0.45820561051368713,
-0.14362101256847382,
-0.3620407283306122,
-0.7964620590209961,
0.15566179156303406,
0.4262508749961853,
-0.3473049998283386,
0.1681976318359... | |
the priority of the Thread. We can not change priority of threads in ThreadPool which is by default Normal.
> **P.S.:** The MSDN article [*"The Managed Thread Pool"*](http://msdn.microsoft.com/en-us/library/0ka9477y.aspx "The Managed Thread Pool (page on MSDN)") contains a section titled, *"When Not to Use Thread Pool Threads"*, with a very similar but slightly more complete list of possible reasons for not using the thread pool.
There are lots of reasons why you would need to skip the `ThreadPool`, but if you don't know them then the `ThreadPool` should be good enough for you.
Alternatively, look at the new [Parallel Extensions Framework](https://learn.microsoft.com/en-us/visualstudio/extensibility/debugger/parallel-extension-internals-for-the-dotnet-framework), which has some | [
0.016454389318823814,
-0.3476187288761139,
0.0928221046924591,
0.254138708114624,
0.09963007271289825,
-0.15296103060245514,
-0.0746065154671669,
0.14131386578083038,
-0.5642386674880981,
-0.7495021224021912,
-0.15321260690689087,
0.427227258682251,
-0.058382030576467514,
0.123383209109306... | |
neat stuff in there that may suit your needs without having to use the `ThreadPool`. | [
0.502600371837616,
0.1231444701552391,
-0.05903312563896179,
0.24877414107322693,
0.4224054515361786,
-0.16485494375228882,
-0.03466720134019852,
0.6756911277770996,
-0.2642625570297241,
-0.5512245297431946,
0.21983060240745544,
0.15998201072216034,
-0.07141951471567154,
-0.052511338144540... | |
Being new to Objective-C (but a long term C/++) programmer I'm looking for advice/recommendations on naming conventions for variables.
My personal preference would be to utilize a prefix for instance variables both for clarity within functions and to prevent shadowing of function parameters. However I'm a fan of properties which rules out prefixes (unless you also prefix your property names, which doesn't work too well and looks daft). Similarly I could use the "self.variable" convention, but only if I make EVERYTHING a property.
So given the code below what's your preferred naming style for instance/function variables? And if you don't bother, how | [
0.3900105059146881,
0.26469752192497253,
0.018041623756289482,
-0.12037896364927292,
-0.4295699894428253,
-0.10748936235904694,
0.1761958748102188,
0.02474232390522957,
-0.19086682796478271,
-0.40174734592437744,
0.11769317090511322,
0.7448791861534119,
-0.21351072192192078,
0.217723473906... | |
do you deal with shadowing on function params?
```
@interface GridItem : NSObject
{
CGRect _rect;
...
}
@end
-(void) initFromRect:(CGRect)rect
{
_rect = rect;
...
}
```
Cheers!
Most Cocoa projects use underbar as a non-`IBOutlet` instance variable prefix, and use no prefix for `IBOutlet` instance variables.
The reason I don't use underbars for `IBOutlet` instance variables is that when a nib file is loaded, if you have a setter method for a connected outlet, that setter will be called. *However* this mechanism does *not* use Key-Value Coding, so an IBOutlet whose name is prefixed with an | [
0.26052218675613403,
0.13210363686084747,
0.45192191004753113,
-0.05388469994068146,
-0.14709758758544922,
-0.007850040681660175,
0.07811910659074783,
0.0024632886052131653,
-0.4064079523086548,
-0.31835824251174927,
-0.0606171190738678,
0.5400846600532532,
-0.4444766938686371,
0.078588068... | |
underbar (*e.g.* `_myField`) will *not* be set unless the setter is named exactly like the outlet (*e.g.* `set_myField:`), which is non-standard and gross.
Also, be aware that using properties like `self.myProp` is **not** the same as accessing instance variables. You are **sending a message** when you use a property, just like if you used bracket notation like `[self myProp]`. All properties do is give you a concise syntax for specifying both the getter and setter in a single line, and allow you to synthesize their implementation; they do not actually short-circuit the message dispatch mechanism. If you want to access an | [
0.12484778463840485,
0.17093655467033386,
0.5011753439903259,
-0.19837109744548798,
-0.3371632993221283,
0.1643211841583252,
0.14157763123512268,
-0.05443210154771805,
-0.02923884056508541,
-0.48110201954841614,
-0.06982254981994629,
0.49358871579170227,
-0.3807276785373688,
-0.03059082478... | |
instance variable directly but prefix it with `self` you need to treat `self` as a pointer, like `self->myProp` which really is a C-style field access.
Finally, never use Hungarian notation when writing Cocoa code, and shy away from other prefixes like "f" and "m\_" — that will mark the code as having been written by someone who doesn't "get it" and will cause it to be viewed by suspicion by other Cocoa developers.
In general, follow the advice in the [Coding Guidelines for Cocoa](http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/index.html "Coding Guidelines for Cocoa") document at the [Apple Developer Connection](http://developer.apple.com/ "Apple Developer Connection"), and other developers will be | [
-0.12097113579511642,
0.5454726219177246,
0.10872931033372879,
-0.10558132827281952,
-0.17317689955234528,
-0.20835189521312714,
0.3247118890285492,
0.1837300807237625,
-0.15795667469501495,
-0.6410160660743713,
-0.25170812010765076,
0.5887271761894226,
-0.3349342346191406,
-0.099170997738... | |
able to pick up and understand your code, and your code will work well with all of the Cocoa features that use runtime introspection.
Here's what a window controller class might look like, using my conventions:
```
// EmployeeWindowController.h
#import <AppKit/NSWindowController.h>
@interface EmployeeWindowController : NSWindowController {
@private
// model object this window is presenting
Employee *_employee;
// outlets connected to views in the window
IBOutlet NSTextField *nameField;
IBOutlet NSTextField *titleField;
}
- (id)initWithEmployee:(Employee *)employee;
@property(readwrite, retain) Employee *employee;
@end
// EmployeeWindowController.m
#import "EmployeeWindowController.h"
@implementation EmployeeWindowController
@synthesize employee = _employee;
- (id)initWithEmployee:(Employee *)employee {
if (self = [super | [
-0.15968728065490723,
-0.25488704442977905,
0.4209339916706085,
0.3681757152080536,
0.10590805858373642,
0.0182171743363142,
0.22241100668907166,
-0.21878185868263245,
-0.2068411409854889,
-0.8589468002319336,
-0.20451751351356506,
0.6476056575775146,
-0.3339334726333618,
0.139178588986396... | |
initWithWindowNibName:@"Employee"]) {
_employee = [employee retain];
}
return self;
}
- (void)dealloc {
[_employee release];
[super dealloc];
}
- (void)windowDidLoad {
// populates the window's controls, not necessary if using bindings
[nameField setStringValue:self.employee.name];
[titleField setStringValue:self.employee.title];
}
@end
```
You'll see that I'm using the instance variable that references an `Employee` directly in my `-init` and `-dealloc` method, while I'm using the property in other methods. That's generally a good pattern with properties: Only ever touch the underlying instance variable for | [
-0.21024084091186523,
-0.11153760552406311,
0.7293292880058289,
-0.3369310796260834,
0.23255927860736847,
-0.20901666581630707,
0.23535627126693726,
-0.043651070445775986,
-0.06316319853067398,
-0.7816982269287109,
-0.35886308550834656,
0.5757243037223816,
-0.3055484890937805,
0.0816654860... | |
a property in initializers, in `-dealloc`, and in the getter and setter for the property. | [
-0.4668446481227875,
0.11693767458200455,
0.06333938241004944,
-0.12767447531223297,
-0.10174135863780975,
-0.22184918820858002,
-0.13505244255065918,
-0.3565715253353119,
0.07403440773487091,
-0.44293785095214844,
-0.6036471724510193,
0.5255349278450012,
0.06157151609659195,
0.20984841883... | |
I have a project where I would like to generate a report export in MS Word format. The report will include images/graphs, tables, and text. What is the best way to do this? Third party tools? What are your experiences?
The answer is going to depend slightly upon if the application is running on a server or if it is running on the client machine. If you are running on a server then you are going to want to use one of the XML based office generation formats as there are know issues when [using Office Automation on a server](http://support.microsoft.com/kb/257757).
However, if | [
0.5011587738990784,
0.257329523563385,
0.3633480966091156,
0.28262633085250854,
-0.18555733561515808,
-0.19876724481582642,
0.06826455891132355,
0.014607017859816551,
-0.2664736807346344,
-0.7344343066215515,
-0.10870826244354248,
0.2724251449108124,
-0.07804067432880402,
-0.00608429638668... | |
you are working on the client machine then you have a choice of either [using Office Automation](http://msdn.microsoft.com/en-us/office/default.aspx) or using the Office Open XML format (see links below), which is supported by Microsoft Office 2000 and up either natively or through service packs. One draw back to this though is that you might not be able to embed some kinds of graphs or images that you wish to show.
The best way to go about things will all depend sightly upon how much time you have to invest in development. If you go the route of Office Automation there are quite | [
0.534161388874054,
0.26108887791633606,
0.27858442068099976,
-0.009882444515824318,
-0.023632686585187912,
-0.2208416759967804,
-0.01911032944917679,
0.20402193069458008,
-0.326533704996109,
-0.7504144310951233,
-0.5000250935554504,
0.41622573137283325,
-0.12147047370672226,
-0.04426187649... | |
a few good tutorials out there that can be found via Google and is fairly simple to learn. However, the Open Office XML format is fairly new so you might find the learning curve to be a bit higher.
Office Open XML Iinformation
* Office Open XML - <http://en.wikipedia.org/wiki/Office_Open_XML>
* OpenXML Developer - <http://openxmldeveloper.org/default.aspx>
* Introducing the Office (2007) Open XML File Formats - <http://msdn.microsoft.com/en-us/library/aa338205.aspx> | [
-0.16725917160511017,
0.027203600853681564,
0.40857741236686707,
0.19649673998355865,
0.03693311661481857,
-0.4252783954143524,
0.009870856069028378,
0.07783767580986023,
-0.17097438871860504,
-0.46863195300102234,
-0.5335969924926758,
0.38995012640953064,
-0.004144046455621719,
-0.0564756... | |
The 'click sound' in question is actually a system wide preference, so I only want it to be disabled when my application has focus and then re-enable when the application closes/loses focus.
Originally, I wanted to ask this question here on stackoverflow, but I was not yet in the beta. So, after googling for the answer and finding only a little bit of information on it I came up with the following and decided to post it here now that I'm in the beta.
```
using System;
using Microsoft.Win32;
namespace HowTo
{
class WebClickSound
{ | [
0.2749423086643219,
0.07582072168588638,
0.2952415943145752,
-0.36858969926834106,
0.2530911862850189,
-0.22177033126354218,
0.09731625020503998,
0.09127984941005707,
-0.139740988612175,
-0.49753695726394653,
-0.36851075291633606,
0.4262351095676422,
-0.49086132645606995,
0.027988761663436... | |
/// <summary>
/// Enables or disables the web browser navigating click sound.
/// </summary>
public static bool Enabled
{
get
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"AppEvents\Schemes\Apps\Explorer\Navigating\.Current"); | [
-0.13215303421020508,
0.18391165137290955,
0.5417271852493286,
-0.19274863600730896,
0.28911009430885315,
-0.06442797929048538,
0.3644406199455261,
0.11459347605705261,
-0.061069123446941376,
-0.6280372142791748,
-0.682449221611023,
0.5582654476165771,
-0.5643084645271301,
0.15835610032081... | |
string keyValue = (string)key.GetValue(null);
return String.IsNullOrEmpty(keyValue) == false && keyValue != "\"\"";
}
set
{
string keyValue; | [
-0.2201046347618103,
-0.4523037075996399,
0.5331421494483948,
-0.417723685503006,
0.6550897359848022,
-0.029432401061058044,
0.515570342540741,
-0.4352883994579315,
0.0872747078537941,
-0.288097620010376,
-0.45825356245040894,
0.9767029285430908,
-0.3850780129432678,
0.17576995491981506,
... | |
if (value)
{
keyValue = "%SystemRoot%\\Media\\";
if (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor > 0)
{ | [
-0.3456386923789978,
-0.299040287733078,
0.7700557708740234,
-0.1504673808813095,
0.7977342009544373,
-0.0802864134311676,
0.3498746156692505,
-0.09406955540180206,
-0.012806816026568413,
-0.5858117938041687,
-0.5152296423912048,
0.6763612627983093,
-0.3841237723827362,
0.3059707283973694,... | |
// XP
keyValue += "Windows XP Start.wav";
}
else if (Environment.OSVersion.Version.Major == 6) | [
0.22989211976528168,
0.02937106415629387,
0.6451776027679443,
-0.329079270362854,
-0.1453379988670349,
-0.23154470324516296,
0.5108973383903503,
-0.23743677139282227,
-0.13159936666488647,
-0.43936750292778015,
-0.41578197479248047,
0.7715643644332886,
-0.17556804418563843,
0.0516573414206... | |
{
// Vista
keyValue += "Windows Navigation Start.wav";
}
else | [
-0.09457933157682419,
-0.1522059589624405,
0.5041409134864807,
-0.15311329066753387,
0.2501021921634674,
-0.08046746253967285,
0.4296777546405792,
0.0003090452228207141,
-0.10069170594215393,
-0.7806563973426819,
-0.2705528140068054,
0.7080098986625671,
-0.09349846839904785,
0.049455959349... | |
{
// Don't know the file name so I won't be able to re-enable it
return;
} | [
-0.14305095374584198,
0.19629909098148346,
0.0592564232647419,
-0.0828171819448471,
0.5093262791633606,
0.0779070034623146,
0.4604298174381256,
0.2447461038827896,
-0.04468204826116562,
-0.23988798260688782,
-0.3616788983345032,
0.5620943307876587,
0.08593416959047318,
0.1969171166419983,
... | |
}
else
{
keyValue = "\"\"";
} | [
-0.3586462438106537,
-0.19594120979309082,
-0.11714912205934525,
-0.3588351607322693,
0.5960859060287476,
-0.09086616337299347,
0.3011193871498108,
-0.01819932647049427,
0.2563909590244293,
-0.3199545443058014,
-0.36242589354515076,
0.9367993474006653,
-0.1297331303358078,
0.01511494629085... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.