Thursday, February 10, 2011

CCCheck has stopped working

De repente eu começei receber essa mensagem quando faço "build" para um projeto.

image

Problema: O projeto configurando para trabalhar com baseline arquivo nos opoçoes do CodeContracts.

image

Eu acho que isso acontece depois que eu baixei versão pelo source control e isso mudou various arquivos para "read only" (somente leitura) inclusivo o baseline.xml.new arquivo.

A janela do output window mostra o exception:

CodeContracts: Roniz.WCF.P2P.Messages: Unhandled Exception: System.UnauthorizedAccessException: Access to the path …\baseline.xml.new' is denied.

soluçao:

Tirar o "read only" atributo do arquvio/s

Saturday, February 5, 2011

Blog em inglês

Tenho tambêm o mesmo blog mas mais atualizado em inglês… gerlamente eu escrevo primeiro em ingles antes de traduzir para português.
Para quem quiser e nesse endereço:
http://www.roniz.net/

ObservableDictionary do DR WPF com dispatcher

Eu uso o ObservableDictionary que DR WPF forneceu para WPF , porem tive problemas quando mudei o dicionario em thread diferente do que o thread que o dicionario foi criado – os eventos: CollectionChanged / PropertyChanged executaram em thread diferente. (gente como falo "thread" em portugues, mas na nossa lingua de programadores ??? סמיילי )

Entao eu mudei o codigo um pouco para suportar isso. As mudanças sao:

1. Nos constructors adicionei parâmetros opcionais para o dispatcher & DispatcherPriority (padrao para DispatcherPriority.DataBind).

public ObservableDictionary(Dispatcher dispatcher = null,DispatcherPriority dispatcherPriority = DispatcherPriority.DataBind)

{

    _dispatcher = dispatcher;

    _dispatcherPriority = dispatcherPriority;

    _keyedEntryCollection = new KeyedDictionaryEntryCollection<TKey>();

}

2. Nos methodos que executa os OnCollectionChanged and OnPropertyChanged eventos verifiquei se o dispatcher nao e null – e ai executei o evento com o dispatcher no lugar de executar ele no thread que chamou ele.

protected
virtual
void OnCollectionChanged(NotifyCollectionChangedEventArgs args)

{

    var handler = CollectionChanged;

    if (handler != null)

    {

    if (_dispatcher != null)

    {

        if (_dispatcher.CheckAccess())

        {

            handler(this, args);

        }

        else

        {

            _dispatcher.Invoke((Action)(() => handler(this, args)), _dispatcherPriority);

        }

    }

    else

    {

        handler(this, args);

    }

    }

}

O codigo completo esta aqui.